Hi All,
Why does the foll. ques throws ClassCastException
import java.util.*;
class CollectionTest {
public static void main(
String args) throws NullPointerException
{
}
public static void main(String args[])
{
try
{
TreeSet s = new TreeSet();
s.add(new Person(10));
s.add(new Person(20));
System.out.println(s);
}
catch(Exception e)
{
System.out.println(e.toString());
}
}
}
class Person
{
Person(int i)
{
}
}
Regards
Nikhil