-
Notifications
You must be signed in to change notification settings - Fork 0
/
Demo.java
27 lines (22 loc) · 904 Bytes
/
Demo.java
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
import java.util.Set;
import java.util.HashSet;
import java.util.List;
import java.util.ArrayList;
public class Demo {
public static void runDemo(NoEquals foo, NoEquals bar) {
System.out.println("Do foo and bar have the same value? "
+ (foo.getValue() == bar.getValue()));
System.out.println("Are foo and bar the same object (class instance)? "
+ (foo == bar));
Set<NoEquals> demoSet = new HashSet<NoEquals>();
demoSet.add(foo);
demoSet.add(bar);
System.out.println("Set contains " + demoSet.size() + " items.");
List<NoEquals> demoList = new ArrayList<NoEquals>();
demoList.add(foo);
System.out.println("Does demoList contain bar? "
+ demoList.contains(bar));
demoList.remove(bar);
System.out.println("List contains " + demoList.size() + " items.");
}
}