diff options
Diffstat (limited to 'java/10-collections/Test4List.java')
| -rw-r--r-- | java/10-collections/Test4List.java | 38 |
1 files changed, 38 insertions, 0 deletions
diff --git a/java/10-collections/Test4List.java b/java/10-collections/Test4List.java new file mode 100644 index 0000000..c730a80 --- /dev/null +++ b/java/10-collections/Test4List.java @@ -0,0 +1,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); + } + } +} |
