aspose file tools*
The moose likes Programmer Certification (SCJP/OCPJP) and the fly likes about generics and collections Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Certification » Programmer Certification (SCJP/OCPJP)
Bookmark "about generics and collections" Watch "about generics and collections" New topic
Author

about generics and collections

Santhi Bharath
Ranch Hand

Joined: Jun 03, 2008
Posts: 75
here is my code



i can't understand why it compiling successfully!! how compiler knows the toString() method is there or not as the toString() not there in java.lang.Number class .any body can please explain.thanks in advance


thanks and regards<br />Santhi Bharath<br />SCJP 5.0, SCWCD 5.0
ramesh maredu
Ranch Hand

Joined: Mar 15, 2008
Posts: 210



when you instantiate generic class with out using any generic types. it takes Object as generic type.

In above code N is considered as Number because N extends Number.
Number class has toString() method inherited from Object
[ September 30, 2008: Message edited by: ramesh maredu ]

SCJP 1.5 94%.
The greatest glory in living lies not in never falling, but in rising every time we fall.
chander shivdasani
Ranch Hand

Joined: Oct 09, 2007
Posts: 206

java.lang.Number extends java.lang.Object

and Object class has toString() method.


Enjoy, Chander
SCJP 5, Oracle Certified PL/SQL Developer
Santhi Bharath
Ranch Hand

Joined: Jun 03, 2008
Posts: 75
thank you guys i got it
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: about generics and collections