This week's book giveaway is in the Clojure forum.
We're giving away four copies of Clojure in Action and have Amit Rathore and Francis Avila on-line!
See this thread for details.
Win a copy of Clojure in Action this week in the Clojure forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

about generics and collections

 
Santhi Bharath
Ranch Hand
Posts: 75
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
 
ramesh maredu
Ranch Hand
Posts: 210
Eclipse IDE Java Linux
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator


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 ]
 
chander shivdasani
Ranch Hand
Posts: 206
Eclipse IDE Ubuntu
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
java.lang.Number extends java.lang.Object

and Object class has toString() method.
 
Santhi Bharath
Ranch Hand
Posts: 75
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
thank you guys i got it
 
I agree. Here's the link: http://aspose.com/file-tools
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic