wood burning stoves 2.0*
The moose likes Beginning Java and the fly likes Generics Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Murach's Java Servlets and JSP this week in the Servlets forum!
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "Generics" Watch "Generics" New topic
Author

Generics

Juan Manuel Alberto de los Santos
Ranch Hand

Joined: Jun 26, 2008
Posts: 48


Why this compiles ??

if i am passing an object(animal) to the method go (who can only accept integers)

Thanks in advance !
[ July 09, 2008: Message edited by: Juan Manuel Alberto de los Santos ]
Paul Sturrock
Bartender

Joined: Apr 14, 2004
Posts: 10336

It compiles so generics are compatable with legacy code. However, you will have seen a warning:

Type safety: The expression of type List needs unchecked conversion to conform to List<Integer>

letting you know what you are doing is not necessarily safe.


JavaRanch FAQ HowToAskQuestionsOnJavaRanch
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Generics
 
Similar Threads
Regarding Generics
Generics Help please !
Generics Confusion
Questio about castdown and ClassCastException (Certification)
Generics + Polymorphism