From 4801f4a99ef94fe2687fd2255f874f2671b808b7 Mon Sep 17 00:00:00 2001 From: Yashi Tripathi <97374593+tripathiix@users.noreply.github.com> Date: Sat, 22 Oct 2022 11:07:52 +0530 Subject: [PATCH] stack.java --- stack.java | 32 ++++++++++++++++++++++++++++++++ 1 file changed, 32 insertions(+) create mode 100644 stack.java diff --git a/stack.java b/stack.java new file mode 100644 index 0000000..b32e9ab --- /dev/null +++ b/stack.java @@ -0,0 +1,32 @@ +// Java program to add the +// elements in the stack +import java.io.*; +import java.util.*; + +class StackDemo { + + // Main Method + public static void main(String[] args) + { + + // Default initialization of Stack + Stack stack1 = new Stack(); + + // Initialization of Stack + // using Generics + Stack stack2 = new Stack(); + + // pushing the elements + stack1.push(4); + stack1.push("All"); + stack1.push("Geeks"); + + stack2.push("Geeks"); + stack2.push("For"); + stack2.push("Geeks"); + + // Printing the Stack Elements + System.out.println(stack1); + System.out.println(stack2); + } +}