-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy patharraylist.java
More file actions
26 lines (24 loc) · 791 Bytes
/
Copy patharraylist.java
File metadata and controls
26 lines (24 loc) · 791 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
import java.util.*;
public class arraylist {
public static void main(String[] args) {
ArrayList<Integer> list = new ArrayList<>();
System.out.println(list + "->" + list.size());
list.add(10);
list.add(20);
list.add(30);
System.out.println(list + "->" + list.size());
list.add(1,2000);
System.out.println(list + "->" + list.size());
int val = list.get(1);
System.out.println(val);
list.set(1,2000);
System.out.println(list + "->" + list.size());
list.remove(1);
System.out.println(list + "->" + list.size());
ArrayList<String> l2 = new ArrayList<>();
l2.add("hello");
l2.add("Hello");
l2.add("s");
System.out.println(l2+"->" + l2.size());
}
}