-
Notifications
You must be signed in to change notification settings - Fork 0
/
ArrayList
54 lines (43 loc) · 1.39 KB
/
ArrayList
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
44
45
46
47
48
49
50
51
52
53
54
package Collections;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collection;
import java.util.Collections;
import java.util.Iterator;
import java.util.List;
public class DemoList {
@SuppressWarnings("unchecked")
public static void main(String[] args) {
// List<Integer> list1 = new ArrayList<Integer>();
ArrayList<ArrayList<Integer>> x = new ArrayList<ArrayList<Integer>>();
@SuppressWarnings("rawtypes")
ArrayList list1 = new ArrayList();
list1.add(1);
list1.add(2);
list1.add("alekha"); // object conversion // autoBoxing
list1.add(2.00);
list1.add('c');
list1.add(.00f);
list1.add(false);
System.out.println(list1);
System.out.println(list1.get(0));
list1.set(2,"chowdary");
System.out.println(list1);
System.out.println(list1.remove(5));
System.out.println(list1.size());
// Collections.sort(list1);
Iterator itr = list1.iterator();
while(itr.hasNext()) {
System.out.println(itr.next());
}
x.add(new ArrayList<Integer>(Arrays.asList(1,25,23)));
x.add(new ArrayList<Integer>(Arrays.asList(19,28,3)));
x.add(new ArrayList<Integer>(Arrays.asList(18,85,63)));
x.add(new ArrayList<Integer>(Arrays.asList(10,221,274)));
// System.out.println(x);
Iterator<ArrayList<Integer>> itr1 = x.iterator();
while(itr1.hasNext()) {
System.out.println(itr1.next());
}
}
}