Forums Register Login

about generics and collections

+Pie Number of slices to send: Send
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
+Pie Number of slices to send: Send


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 ]
+Pie Number of slices to send: Send
java.lang.Number extends java.lang.Object

and Object class has toString() method.
+Pie Number of slices to send: Send
thank you guys i got it
These are the worst of times and these are the best of times. And this is the best tiny ad:
a bit of art, as a gift, the permaculture playing cards
https://gardener-gift.com


reply
reply
This thread has been viewed 663 times.
Similar Threads
Null Pointer Exception ???
Abstract class??
Dynamic Method Lookup?
query regarding displaying usercontent
how to get the answer as 15 for this code
More...

All times above are in ranch (not your local) time.
The current ranch time is
Mar 29, 2024 02:07:56.