Skip to content

Commit af7068c

Browse files
authored
Merge pull request #39 from Saurabh2509/main
ArrayList.java
2 parents 542c967 + 748f139 commit af7068c

File tree

1 file changed

+23
-0
lines changed

1 file changed

+23
-0
lines changed

ArrayList.java

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
import java.util.*;
2+
public class ArrayList
3+
{
4+
public static void main(String[] args) {
5+
Scanner sc =new Scanner(System.in);
6+
7+
// creating a ArrayList object
8+
ArrayList<Integer> arr = new ArrayList<Integer>();
9+
int n=10;
10+
for(int i=0;i<=5;i++){
11+
// add element and taking input
12+
arr.add(sc.nextInt());
13+
}
14+
//print all elememt
15+
System.out.println(arr);
16+
//remove the 4th index elemet
17+
arr.remove(4);
18+
System.out.println(arr);
19+
//acessing the element by index -->method get(i)
20+
System.out.println(arr.get(2));
21+
22+
}
23+
}

0 commit comments

Comments
 (0)