-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy patharraylistbasics.java
More file actions
43 lines (23 loc) · 829 Bytes
/
Copy patharraylistbasics.java
File metadata and controls
43 lines (23 loc) · 829 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
41
42
43
import java.util.*;
public class getsubsequence {
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
ArrayList<Integer> list= new ArrayList<>();
list.add(10);
list.add(20);
list.add(30);
list.add(40);
System.out.println(list+"->"+list.size());
for(int val:list){ //the way of printing arraylist by using the new type of loop ........
System.out.println(val);
}
for(int i= 0; i<list.size();i++){
int val=list.get(i); //other way of printng the arraylist......
System.out.println(val);
}
list.set(2,300); // replacing the element of the arraylist/.......
System.out.println(list+"->"+list.size());
list.add(3,300000);
System.out.println(list+"->"+list.size());
}
}