summaryrefslogtreecommitdiff
path: root/java/10-collections/Test4List.java
diff options
context:
space:
mode:
authorKamal Wickramanayake <kamal@inbox.lk>2026-02-21 20:33:23 +0530
committerKamal Wickramanayake <kamal@inbox.lk>2026-02-21 20:33:23 +0530
commit530141c542ab3b44991f05016e66db651795e9c9 (patch)
treeabf4953878cd274d06d890c3bcad4e0230b30943 /java/10-collections/Test4List.java
parent3625bc6cbddd473659b3f584c0dbec515c07c786 (diff)
Added java/collections and java/error handling sample code
Diffstat (limited to 'java/10-collections/Test4List.java')
-rw-r--r--java/10-collections/Test4List.java38
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);
+ }
+ }
+}