From 8723afdd221c7a87042ab1a8ba1a6ba05bfb5f00 Mon Sep 17 00:00:00 2001 From: misa Date: Thu, 12 Feb 2026 10:01:53 +0000 Subject: [PATCH] Upload files to "/" --- TreeSet18a.java | 19 +++++++++++++++++++ TreeSet18b.java | 19 +++++++++++++++++++ Vector14a.java | 18 ++++++++++++++++++ Vector14b.java | 21 +++++++++++++++++++++ 4 files changed, 77 insertions(+) create mode 100644 TreeSet18a.java create mode 100644 TreeSet18b.java create mode 100644 Vector14a.java create mode 100644 Vector14b.java diff --git a/TreeSet18a.java b/TreeSet18a.java new file mode 100644 index 0000000..ac5e2a6 --- /dev/null +++ b/TreeSet18a.java @@ -0,0 +1,19 @@ +//18a. write a java code to demonstrate tree set +import java.util.*; +public class TreeSet18a +{ + public static void main(String[] args) + { + TreeSet brands = new TreeSet(); + brands.add("YSL"); + brands.add("Prada"); + brands.add("Louboutin"); + brands.add("Maybellin"); + brands.add("YSL"); + Iterator itr = brands.iterator(); + while(itr.hasNext()) + { + System.out.println(itr.next()); + } + } +} \ No newline at end of file diff --git a/TreeSet18b.java b/TreeSet18b.java new file mode 100644 index 0000000..c8d3a4f --- /dev/null +++ b/TreeSet18b.java @@ -0,0 +1,19 @@ +//18b. write a java code to demonstrate tree set +import java.util.*; +public class TreeSet18b +{ + public static void main(String[] args) + { + TreeSet brands = new TreeSet(); + brands.add("YSL"); + brands.add("Prada"); + brands.add("Louboutin"); + brands.add("null"); + brands.add("YSL"); + Iterator itr = brands.iterator(); + while(itr.hasNext()) + { + System.out.println(itr.next()); + } + } +} \ No newline at end of file diff --git a/Vector14a.java b/Vector14a.java new file mode 100644 index 0000000..c14da91 --- /dev/null +++ b/Vector14a.java @@ -0,0 +1,18 @@ +//14(a). write a java code to demonstrate vector +import java.util.*; +public class Vector14a +{ + public static void main(String[] args) + { + Vector name=new Vector(); + name.add("Misa"); + name.add("Aditya"); + name.add("Shyam"); + name.add("Aisha"); + Iterator itr=name.iterator(); + while(itr.hasNext()) + { + System.out.println(itr.next()); + } + } +} diff --git a/Vector14b.java b/Vector14b.java new file mode 100644 index 0000000..456602d --- /dev/null +++ b/Vector14b.java @@ -0,0 +1,21 @@ +import java.util.Vector; +public class Vector14b { + public static void main(String args[]){ + Vector groceryList = new Vector(); + groceryList.add("Bread"); + groceryList.add("Milk"); + groceryList.add("Eggs"); + + System.out.println("Item at index 0: " + groceryList.get(0)); + System.out.println("Item at index 1: " + groceryList.get(1)); + System.out.println("Item at index 2: " + groceryList.get(2)); + + System.out.println("Items in Grocery list: "); + for(String item: groceryList) { + System.out.println(item); + } + + itemList.remove(groceryList.get(2)); + System.out.println("Size of grocery after removal: " + groceryList.size()); + } +} \ No newline at end of file