From 42cd8cd5b42bdf60bd098e094ace7860940e74a3 Mon Sep 17 00:00:00 2001 From: misa Date: Sun, 15 Feb 2026 14:32:14 +0000 Subject: [PATCH] Upload files to "/" --- LinkedList13b.java | 18 ++++++++++++++++++ Stack15.java | 31 +++++++++++++++++++++++++++++++ 2 files changed, 49 insertions(+) create mode 100644 LinkedList13b.java create mode 100644 Stack15.java diff --git a/LinkedList13b.java b/LinkedList13b.java new file mode 100644 index 0000000..706e65e --- /dev/null +++ b/LinkedList13b.java @@ -0,0 +1,18 @@ +//program 13b +import java.util.*; +public class LinkedList13b +{ + public static void main(String[] args) + { + LinkedList name1=new LinkedList(); + name1.add("Misa"); + name1.add("Aditya"); + name1.add("Aisha"); + name1.add("Aditya"); + Iterator itr=name1.iterator(); + while(itr.hasNext()) + { + System.out.println(itr.next()); + } + } +} \ No newline at end of file diff --git a/Stack15.java b/Stack15.java new file mode 100644 index 0000000..3e39e10 --- /dev/null +++ b/Stack15.java @@ -0,0 +1,31 @@ +//15. write a java code to demonstrate stack +import java.util.*; +public class Stack15 +{ + public static void main(String[] args) + { + Stack food = new Stack(); + food.push("\nButter Chicken"); + food.push("Dal Makhani"); + food.push("Kadhai Paneer"); + food.push("Prawns Koliwada"); + food.push("Crab Soup"); + Iterator itr = food.iterator(); + while(itr.hasNext()) + { + System.out.println(itr.next()); + } + String Food = food.peek(); + System.out.println("\nThe Top food item is: " +Food); + + food.pop(); + System.out.println("\nAfter Pop:"); + Iterator newItr = food.iterator(); + while(newItr.hasNext()) + { + System.out.println(newItr.next()); + } + } +} + + \ No newline at end of file