Win a copy of Soft Skills: The software developer's life manual this week in the Jobs Discussion forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Java 5, Collections warning in Eclipse

 
colin shuker
Ranch Hand
Posts: 750
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 2399
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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>.
 
It is sorta covered in the JavaRanch Style Guide.
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic