This week's book giveaway is in the General Computing forum.
We're giving away four copies of Arduino in Action and have Martin Evans, Joshua Noble, and Jordan Hochenbaum on-line!
See this thread for details.
The moose likes Java in General and the fly likes Java 5, Collections warning in Eclipse Big Moose Saloon
  Search | Java FAQ | Recent Topics
Register / Login


JavaRanch » Java Forums » Java » Java in General
Reply Bookmark "Java 5, Collections warning in Eclipse" Watch "Java 5, Collections warning in Eclipse" New topic
Author

Java 5, Collections warning in Eclipse

colin shuker
Ranch Hand

Joined: Apr 11, 2005
Posts: 712
Hi, I'm using Java 5.0, with Eclipse.
I have this code below, which gives a warning as stated below:



The word comp gets underlined in yellow in eclipse, as shown above in italics, and it says:

Type safety: The expression of type Comp needs unchecked conversion to conform to Comparator<? super SetObj>


Can anyone explain what this means and how I can fix it without just supressing the warning.

Thanks
[ April 19, 2007: Message edited by: colin shuker ]
Keith Lynn
Ranch Hand

Joined: Feb 07, 2005
Posts: 2341
The reason is that you are trying to create a TreeSet with a type by using a Comparator that has a raw type.

To get rid of the warning, instead of implementing the raw interface Comparator, you can implement the interface Comparator<SetObj>.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Java 5, Collections warning in Eclipse
 
Similar Threads
making a mostly anonymous Comparator be Serializable
TreeSet adding twice null
Sorting Collection
default JFileChooser to details view Mode
how sort a array of files and directories.. ?