From 530141c542ab3b44991f05016e66db651795e9c9 Mon Sep 17 00:00:00 2001 From: Kamal Wickramanayake Date: Sat, 21 Feb 2026 20:33:23 +0530 Subject: Added java/collections and java/error handling sample code --- java/10-collections/Test4List.java | 38 ++++++++++++++++++++++++++++++++++++++ 1 file changed, 38 insertions(+) create mode 100644 java/10-collections/Test4List.java (limited to 'java/10-collections/Test4List.java') 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 list = new ArrayList(); + +// List 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); + } + } +} -- cgit v1.2.3