forked from rakhi2207/java-programs-
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathuseArrayListinJava.java
More file actions
37 lines (28 loc) · 811 Bytes
/
useArrayListinJava.java
File metadata and controls
37 lines (28 loc) · 811 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
package com.harsh;
import java.util.*;
public class ArrayListExample
{
public static void main(String args[])
{
ArrayList list = new ArrayList();
System.out.println("Initial size of list :" +
" " + list.size());
list.add("A");
list.add("B");
list.add("C");
list.add("D");
list.add("E");
list.add("F");
list.add(1, "1");
System.out.println("Size after addition :" +
" " +list.size());
System.out.println("Contents of list: " + list);
for(Object str : list)
System.out.println(str);
list.remove("F");
list.remove(2);
System.out.println("Size of after deletion : "
+ list.size());
System.out.println("Contents of list : " + list);
}
}