• Post Reply Bookmark Topic Watch Topic
  • New Topic

Warnings after compiling program using Generics  RSS feed

 
Jignesh Gohel
Ranch Hand
Posts: 276
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,

I have made my first program using Generic .It gets compiled with the following warnings:

GenericFirst.java:18: warning: [unchecked] unchecked call to add(E) as a member
of the raw type java.util.List
list.add("Hi!");
^
GenericFirst.java:19: warning: [unchecked] unchecked call to add(E) as a member
of the raw type java.util.List
list.add(42);


I am not able to understand what dos it want to say??

So please let me know what these warnings indicate & how to remove that??
 
Ernest Friedman-Hill
author and iconoclast
Sheriff
Posts: 24217
38
Chrome Eclipse IDE Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
The problem is that in this code you've ignored generics. The error message is letting you know that you've created a List that's not parameterized -- a "pre-generics" list that isn't type-safe. Java won't let you do this without warnings anymore.

Do you understand what I'm saying?
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!