java - Type safety: the method is of the original type and should reference a generic reference

Eclipse gives me the warning (in the title) using just the following code in a working project with nothing in it but a dummy class and a main method:

List a = new ArrayList();
List<Integer> b = new ArrayList<Integer>();
int x = 19;
a.add(x);

The last line triggers the warning. I'm not sure what I am doing wrong here, or really, what I am even doing. I am a Java student following a dubious tutorial and I am attempting to understand generics. Supposedly, variable x doesn't illustrate type safety. I tried casting it to the Object type (which I think does nothing because it already is) and it didn't work.

How might I resolve this warning?

This question and all comments follow the "Attribution Required."

All Answers

Answers Loading...
Leave a Reply
You must be logged in to post a answer.
About the author