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?
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…