Biblioteca Java - Blame information for rev 2
Subversion Repositories:
Rev | Author | Line No. | Line |
---|---|---|---|
2 | mihai | 1 | package colectii.set; |
2 | |||
3 | import java.util.*; | ||
4 | public class TestSet1 { | ||
5 | |||
6 | static void displayAll(Set list){ | ||
7 | System.out.println("- - - - - - - -"); | ||
8 | Iterator i = list.iterator(); | ||
9 | while(i.hasNext()){ | ||
10 | String s = (String)i.next(); | ||
11 | System.out.println(s); | ||
12 | } | ||
13 | } | ||
14 | |||
15 | /** | ||
16 | * @param args | ||
17 | */ | ||
18 | public static void main(String[] args) { | ||
19 | |||
20 | HashSet set = new HashSet(); | ||
21 | set.add("one");set.add("tow");set.add("six");set.add("six"); | ||
22 | set.add("one");set.add("four");set.add("five"); | ||
23 | displayAll(set); | ||
24 | |||
25 | TreeSet tree = new TreeSet(); | ||
26 | tree.add("one");tree.add("tow");tree.add("six");tree.add("six"); | ||
27 | tree.add("one");tree.add("four");tree.add("five"); | ||
28 | displayAll(tree); | ||
29 | |||
30 | LinkedHashSet lnk = new LinkedHashSet(); | ||
31 | lnk.add("one");lnk.add("tow");lnk.add("six");lnk.add("six"); | ||
32 | lnk.add("one");lnk.add("four");lnk.add("five"); | ||
33 | displayAll(lnk); | ||
34 | } | ||
35 | } |