-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathArrayList1.java
More file actions
40 lines (28 loc) · 751 Bytes
/
ArrayList1.java
File metadata and controls
40 lines (28 loc) · 751 Bytes
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
import java.util.ArrayList;
public class ArrayList1 {
public static void main(String[] args) {
ArrayList<Integer> l1= new ArrayList<>();
ArrayList<Integer> l2 =new ArrayList<>(5) ;
l1.add(6);
l1.add(5);
l1.add(4);
l1.add(2);
l2.add(10);
l2.add(20);
l2.add(40);
l2.add(30);
l1.add(0,5);
l1.add(0,1);
l1.set(1, 121);
l1.addAll(l2);
//l1.clear();
l1.add(0,5);
System.out.println(l1.contains(27));
System.out.println(l1.indexOf(2));
for(int i=0;i<l1.size();i++)
{
System.out.print(l1.get(i));
System.out.print(", ");
}
}
}