From 754fdf5d6aec967a7acda17245a4c4834786ed98 Mon Sep 17 00:00:00 2001 From: truptiwagh13 <114471716+truptiwagh13@users.noreply.github.com> Date: Wed, 12 Oct 2022 22:19:15 +0530 Subject: [PATCH] Create stack.java --- stack.java | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) create mode 100644 stack.java diff --git a/stack.java b/stack.java new file mode 100644 index 0000000..0c9f8c9 --- /dev/null +++ b/stack.java @@ -0,0 +1,21 @@ +import java.util.Stack; +public class StackEmptyMethodExample +{ +public static void main(String[] args) +{ +//creating an instance of Stack class +Stack stk= new Stack<>(); +// checking stack is empty or not +boolean result = stk.empty(); +System.out.println("Is the stack empty? " + result); +// pushing elements into stack +stk.push(78); +stk.push(113); +stk.push(90); +stk.push(120); +//prints elements of the stack +System.out.println("Elements in Stack: " + stk); +result = stk.empty(); +System.out.println("Is the stack empty? " + result); +} +}