-
Notifications
You must be signed in to change notification settings - Fork 2
/
CollList.java
50 lines (50 loc) · 1.09 KB
/
CollList.java
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
import java.util.*;
public class CollList {
public static void main(String[] args)
{
List v= new ArrayList();
v.add(10); // add the elemnts in the list
v.add(200);
v.add(40);
v.add(50);
v.add(600);
v.add(600);
v.add(400);
v.add("hello");
System.out.println(v);
List newlist = new ArrayList();
newlist.add(800);
newlist.add(340);
System.out.println(newlist);
v.addAll(newlist);
//System.out.println(v);
//System.out.println(v.get(2));
//v.remove(3);
////System.out.println(v);
// v.remove(Integer.valueOf(600));
// v.add(2,300);
//v.set(2, 220);
System.out.println(v);
//v.set(2,1000);
//System.out.println(v.contains(220));
v.clear();
System.out.println(v);
//
//Collections.sort(v);
//System.out.println(v.size());
//v.add("hello");
//System.out.println(v);
//System.out.println(v);
// for(int i=0;i<v.size();i++)
// System.out.println("simple traversal "+v.get(i));
// Iterator<Integer> i=v.iterator();
// while(i.hasNext())
// {
// System.out.println(i.next());
// }
for(Object x: v)
{
System.out.println("via for each loop "+x);
}
}
}