-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathArraylist.java
More file actions
31 lines (28 loc) · 777 Bytes
/
Arraylist.java
File metadata and controls
31 lines (28 loc) · 777 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
// package com.company;
// import java.lang.reflect.Array;
import java.util.*;
public class Arraylist {
public static void main(String[] args) {
ArrayList<Integer> l1 = new ArrayList<>();
ArrayList<Integer> l2 = new ArrayList<>(5);
l2.add(15);
l2.add(18);
l2.add(19);
l1.add(6);
l1.add(7);
l1.add(4);
l1.add(6);
l1.add(0, 5);
l1.add(0, 1);
l1.addAll(0, l2);
System.out.println(l1.contains(27));
System.out.println(l1.indexOf(6));
System.out.println(l1.lastIndexOf(6));
//l1.clear();
l1.set(1, 566);
for(int i=0; i<l1.size(); i++){
System.out.print(l1.get(i));
System.out.print(", ");
}
}
}