-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathTestSet3.java
More file actions
29 lines (28 loc) · 857 Bytes
/
TestSet3.java
File metadata and controls
29 lines (28 loc) · 857 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
import java.util.*;
class TestSet3{
public static void main(String[] args) {
TreeSet tree = new TreeSet();
tree.add("one");
tree.add("two");
tree.add("three");
tree.add("four");
tree.add("five");
System.out.println(tree);
//tree.add(10);
/*
Exception in thread "main" java.lang.ClassCastException: java.lang.String cannot
be cast to java.lang.Integer
at java.lang.Integer.compareTo(Unknown Source)
at java.util.TreeMap.put(Unknown Source)
at java.util.TreeSet.add(Unknown Source)
at TestSet3.main(TestSet3.java:12)
*/
//tree.add(null);
/*
Exception in thread "main" java.lang.NullPointerException
at java.util.TreeMap.put(Unknown Source)
at java.util.TreeSet.add(Unknown Source)
at TestSet3.main(TestSet3.java:21)
*/
}
}