Granny's Programming Pearls
"inside of every large program is a small program struggling to get out"
JavaRanch.com/granny.jsp
The moose likes Beginning Java and the fly likes generics Big Moose Saloon
  Search | Java FAQ | Recent Topics
Register / Login
JavaRanch » Java Forums » Java » Beginning Java
Reply Bookmark "generics "uses unchecked or unsafe operations" problem" Watch "generics "uses unchecked or unsafe operations" problem" New topic
Author

generics "uses unchecked or unsafe operations" problem

Dinah Gans
Greenhorn

Joined: Feb 15, 2010
Posts: 8
Can someone help me understand why this gives me the following Notes?

I don't understand why my constructor doesn't seem to be using generics for myList even though when I created it I said it held generics? Thanks in advance for the help!

Note: InfiniteInt.java uses unchecked or unsafe operations.
Note: Recompile with -Xlint:unchecked for details.




My DLList class uses objects:





Dinah
Rob Spoor
Sheriff

Joined: Oct 27, 2005
Posts: 19216

InfiniteInt extends the raw type DLList. You should move the Integer generic type to DLList instead:
And you should know that Integer is final so there are no subclasses of Integer


SCJP 1.4 - SCJP 6 - SCWCD 5
How To Ask Questions How To Answer Questions
Dinah Gans
Greenhorn

Joined: Feb 15, 2010
Posts: 8
Wow thanks!!! That solved all of the problems I was having with this & explains why it was telling me "DLList<Integer> cannot be applied to (int)" when I had changed both classes to have generics.
Rob Spoor
Sheriff

Joined: Oct 27, 2005
Posts: 19216

You're welcome.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: generics "uses unchecked or unsafe operations" problem
 
Similar Threads
Generics
Generics: warnings
Generics
generics
Generics warnings... I don't understand?!