@@ -15,25 +15,41 @@ public static void main(String[] args) {
15
15
list .add ("One" );
16
16
list .add ("Two" );
17
17
list .add ("One" );
18
+ System .out .println ("Initial List" );
19
+ System .out .println (list );
18
20
19
21
Set <String > set = new HashSet <>();
20
22
set .add ("Three" );
21
23
set .add ("Four" );
22
24
set .add ("One" );
23
-
25
+ System . out . println ( "Initial Set" );
24
26
System .out .println (set );
27
+
28
+ //Adding all list elements to Set Collection
25
29
set .addAll (list );
30
+ System .out .println ("Adding list to set collection" );
26
31
System .out .println (set );
27
32
33
+ //Adding array values to List Collection
34
+ String strArray [] = {"ABC" ,"acb" };
35
+ Collections .addAll (list , strArray );
36
+ System .out .println ("Adding Array values to List collection " );
37
+ System .out .println (list );
38
+
39
+ //sorting the List Collection
28
40
Collections .sort (list );
29
- System .out .println ("Sort : " +list );
41
+ System .out .println ("Sorting the List : " );
42
+ System .out .println (list );
43
+
44
+ //sorting the list with comparator - reverse order
30
45
Collections .sort (list , Collections .reverseOrder ());
31
- System .out .println ("Reverse Order : " +list );
46
+ System .out .println ("Reverse Order : " );
47
+ System .out .println (list );
32
48
33
49
String max = Collections .max (list );
34
- System .out .println ("Max : " +max );
50
+ System .out .println ("Max Element in the List : " +max );
35
51
String min = Collections .min (list );
36
- System .out .println ("Min : " +min );
52
+ System .out .println ("Min Element in the List : " +min );
37
53
38
54
List <Integer > iList = new ArrayList <>();
39
55
iList .add (10 );
@@ -69,5 +85,7 @@ public static void main(String[] args) {
69
85
70
86
Map <Integer , String > map = new HashMap <>();
71
87
map = Collections .synchronizedMap (map );
88
+
89
+
72
90
}
73
- }
91
+ }
0 commit comments