aspose file tools*
The moose likes Java in General and the fly likes Generics unchecked assignment Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Java in General
Bookmark "Generics unchecked assignment" Watch "Generics unchecked assignment" New topic
Author

Generics unchecked assignment

Justin Chu
Ranch Hand

Joined: Apr 19, 2002
Posts: 209
    
    1
I'm starting to apply generics to some code.

In this example:

The most generic way of using generics is


This causes "Unchecked assignment: 'java.util.Set' to 'java.util.Collection <? extends java.lang.Object>'". Can this warning be resolved without modifying the classroom class?
Rob Spoor
Sheriff

Joined: Oct 27, 2005
Posts: 19784
    
  20

If classroom.getStudentSet() returns just a Set, without generics, then no. The only thing to do is either change the classroom class, or use @SuppressWarnings("unchecked") on that variable or the method/constructor.


SCJP 1.4 - SCJP 6 - SCWCD 5 - OCEEJBD 6
How To Ask Questions How To Answer Questions
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Generics unchecked assignment