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 The Java EE 7 Tutorial Volume 1 or Volume 2 this week in the Java EE forum
or jQuery UI in Action in the JavaScript forum!
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "generics" Watch "generics" New topic
Author

generics

saravanan ragunathan
Ranch Hand

Joined: Aug 02, 2010
Posts: 84
the below code doesn't give errors


but this code generates Incomptible types error


what is the difference between the two ...i expected the same error for first code


"I Love Java Ranch"
Rob Spoor
Sheriff

Joined: Oct 27, 2005
Posts: 19672
    
  18

What if T is replaced with Integer or String?


SCJP 1.4 - SCJP 6 - SCWCD 5 - OCEEJBD 6
How To Ask Questions How To Answer Questions
Henry Wong
author
Sheriff

Joined: Sep 28, 2004
Posts: 18747
    
  40

All objects inherits from the Object class type. The reverse is not true. The compiler would complain even if you used a specific type (and not generics) here.

[EDIT: Beaten to the answer again]

Henry


Books: Java Threads, 3rd Edition, Jini in a Nutshell, and Java Gems (contributor)
saravanan ragunathan
Ranch Hand

Joined: Aug 02, 2010
Posts: 84
thanks henry....i understand the concept

 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: generics