-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathAssignment101_.java
More file actions
75 lines (43 loc) · 2.33 KB
/
Assignment101_.java
File metadata and controls
75 lines (43 loc) · 2.33 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
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
package abhilash_Asignments;
import java.util.ArrayList;
//WAP using Collection methods?
public class Assignment101_ {
public static void main(String[] args) {
ArrayList L1 = new ArrayList(); // creating the Array list
L1.add("Ben10"); // Adding the values or elements with the help of variablename.add
L1.add("Dora Mon");
L1.add("Chota Beem");
L1.add("Kid Vs Cat");
L1.add("Power Rangers");
L1.add("He-MAN");
System.out.println(L1); // print the arraylist
System.out.println("==============================================");
L1.add(7890); // we can add diffrent data in arraylist
System.out.println("After Adding the Numeric values : " + L1); // Add method in collection --->1
System.out.println("==============================================");
ArrayList L2 = new ArrayList();
L2.addAll(L1); // Addall method in collection
System.out.println("After adding the L1 collection to L2 collection :- " + L2);
System.out.println("==============================================");
boolean B3 = L2.contains("Power Rangers"); // Contains(object) method
System.out.println("Output of contain object Retun type Boolean : - " + B3);
System.out.println("==============================================");
boolean B4 = L2.containsAll(L1); //// Contains(collection) method
System.out.println("Output of contain Collection Retun type Boolean: - " + B4);
System.out.println("==============================================");
boolean B5 = L2.isEmpty(); //// isempty(boolean) method
System.out.println("Output of is empty object Retun type Boolean: - " + B5);
System.out.println("==============================================");
L1.remove(3); // remove method by using index number remove object
System.out.println("object removed with help of remove method by using index number" + L1);
System.out.println("==============================================");
L2.removeAll(L1); // removeall method (colection) not getting
System.out.println(L2);
System.out.println("==============================================");
int A2 = L1.size(); // size method to know exact size of collection
System.out.println("size of L1 collection : " + A2);
System.out.println("==============================================");
L1.clear();
System.out.println("Clearing the data or elements in L1 collection : " + L1);
}
}