-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathApp.java
More file actions
58 lines (41 loc) · 1.01 KB
/
Copy pathApp.java
File metadata and controls
58 lines (41 loc) · 1.01 KB
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
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
package tutorial60;
import java.util.ArrayList;
import java.util.Collection;
import java.util.List;
import java.util.SortedSet;
import java.util.TreeSet;
class Person{
private String name;
public String getName() {
return name;
}
public Person(String name){
this.name=name;
}
public String toString() {
return name;
}
}
public class App {
public static void main(String[] args) {
List<Person> list = new ArrayList<Person>();
SortedSet<Person> set = new TreeSet<Person>();
addElements(list);
addElements(set);
//Collections.sort((List<T>) list);
showElements(list);
showElements(set);
}
private static void addElements(Collection<Person> col) {
col.add(new Person("joe"));
col.add(new Person("sue"));
col.add(new Person("juliet"));
col.add(new Person("clare"));
col.add(new Person("mike"));
}
private static void showElements(Collection<Person> col) {
for (Person element : col) {
System.out.println(element);
}
}
}