-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathArrayVsArrayList.java
More file actions
35 lines (30 loc) · 885 Bytes
/
Copy pathArrayVsArrayList.java
File metadata and controls
35 lines (30 loc) · 885 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
import java.util.ArrayList;
public class ArrayVsArrayList {
public static void main(String[] args) {
int arr[] = new int[5];
for(int e : arr){
System.out.println(e);
}
ArrayList<Integer> list = new ArrayList<>();
Object o = 10;
list.add(10);
list.add(20);
list.add(30);
list.add(10);
list.add(10);
list.add(0,99);
list.removeIf((Integer element)->element==10);
//System.out.println(list);
// list.remove(o);
System.out.println(list);
//list.remove(100);
list.set(0, 11111);
System.out.println(list);
ArrayList<String> names = new ArrayList<>();
names.add("amit");
names.add("ram");
names.add("shyam");
names.remove("ram");
System.out.println(names);
}
}