summaryrefslogtreecommitdiff
path: root/java/10-collections/Test4List.java
blob: c730a80ed52403a87cfbc3d5268274cb99e724b0 (plain)
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
import java.util.ArrayList;
import java.util.Collections;
import java.util.Iterator;
import java.util.List;

public class Test4List {

	/**
	 * @param args
	 */
	public static void main(String[] args) {
		List<Customer> list = new ArrayList<Customer>();

//		List<Customer> syncList = Collections.synchronizedList(list);
		
		list.add(new Customer("Nuwan"));
		list.add(new Customer("Lasitha"));
		list.add(new Customer("Praveen"));
		
		Customer x = list.get(2);
		System.out.println(x);
		
//		list.
		list.add(2, new Customer("Kamal"));
		
		Customer y = new Customer("ABC");
		Customer z = new Customer("ABC");
		
		list.add(y);
		list.add(y);
		list.add(z);
		
		for (Customer c : list) {
			// Do some work with c here
			System.out.println(c);
		}
	}
}