forked from dameeta/JavaRepo
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathConcurrentSkipListSetLastExample1
More file actions
51 lines (41 loc) · 1.42 KB
/
ConcurrentSkipListSetLastExample1
File metadata and controls
51 lines (41 loc) · 1.42 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
import java.util.*;
import java.util.concurrent.ConcurrentSkipListSet;
class ConcurrentSkipListSetLastExample1 {
public static void main(String[] args)
{
// Initializing the set using
// ConcurrentSkipListSet()
ConcurrentSkipListSet<Integer> set
= new ConcurrentSkipListSet<Integer>();
// Adding elements to this set
set.add(78);
set.add(64);
set.add(12);
set.add(45);
set.add(8);
// Printing the ConcurrentSkipListSet
System.out.println("ConcurrentSkipListSet: " + set);
// Initializing the set using
// ConcurrentSkipListSet(Collection)
ConcurrentSkipListSet<Integer> set1
= new ConcurrentSkipListSet<Integer>(set);
// Printing the ConcurrentSkipListSet1
System.out.println("ConcurrentSkipListSet1: "
+ set1);
// Initializing the set using
// ConcurrentSkipListSet()
ConcurrentSkipListSet<String> set2
= new ConcurrentSkipListSet<>();
// Adding elements to this set
set2.add("Apple");
set2.add("Lemon");
set2.add("Banana");
set2.add("Apple");
// creating an iterator
Iterator<String> itr = set2.iterator();
System.out.print("Fruits Set: ");
while (itr.hasNext()) {
System.out.print(itr.next() + " ");
}
}
}