posted 18 years ago
No, Ali, Did you compile the above code?
This code compiles fine but gives runtime exception because
of mutual incomparability between treeset objects. One object
is Integer and another is Double.
TreeSet uses Comparable interface's compareTo(...) method that
is implemented by the objects inserted into, tokeep the objects
in sorted manner. And an Integer and an Double can't be compared
because they are not mutually comparable as Keith said
already.
Regards,
cmbhatt
[ April 24, 2007: Message edited by: Chandra Bhatt ]