-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy patharraylist.java
More file actions
45 lines (31 loc) · 1 KB
/
arraylist.java
File metadata and controls
45 lines (31 loc) · 1 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
import java.util.ArrayList;
public class arraylist {
public static void main(String[] args) {
ArrayList<Integer> l1= new ArrayList<>();
ArrayList<Integer> l2= new ArrayList<>(4);
l1.add(3);
l1.add(4);
l1.add(5);
l1.add(7);
l2.add(13);
l2.add(17);
l2.add(16);
for(int i=0; i<l1.size(); i++){
System.out.println(l1.get(i));
}
System.out.println(" ");
l1.addAll(0, l2);
for(int i=0; i<l1.size(); i++){
System.out.println(l1.get(i));
}
//System.out.println(" ");
//l1.clear();
//for(int i=0; i<l1.size(); i++){
// System.out.println(l1.get(i));
// }
System.out.println(" ");
System.out.println(l1.contains(12));
System.out.println(" ");
System.out.println(l1.indexOf(4));
}
}