File tree Expand file tree Collapse file tree 1 file changed +0
-31
lines changed
src/main/java/com/thealgorithms/stacks Expand file tree Collapse file tree 1 file changed +0
-31
lines changed Original file line number Diff line number Diff line change @@ -56,34 +56,3 @@ public boolean isEmpty() {
5656 return size == 0 ;
5757 }
5858}
59- class demo {
60- public static void main (String [] args ) {
61- StackUsingLinkedList <Integer > stack = new StackUsingLinkedList <>();
62-
63- System .out .println ("Is stack empty? " + stack .isEmpty ());
64- System .out .println ("Initial size: " + stack .size ());
65-
66-
67- stack .push (10 );
68- stack .push (20 );
69- stack .push (30 );
70-
71- System .out .println ("After pushes:" );
72- System .out .println ("Top element: " + stack .peek ()); // 30
73- System .out .println ("Size: " + stack .size ()); // 3
74-
75- // Pop elements
76- System .out .println ("Popped: " + stack .pop ()); // 30
77- System .out .println ("Popped: " + stack .pop ()); // 20
78-
79- System .out .println ("After pops:" );
80- System .out .println ("Top element: " + stack .peek ()); // 10
81- System .out .println ("Size: " + stack .size ()); // 1
82-
83- System .out .println ("Is stack empty? " + stack .isEmpty ());
84-
85-
86- stack .pop ();
87- System .out .println ("Is stack empty after final pop? " + stack .isEmpty ());
88- }
89- }
You can’t perform that action at this time.
0 commit comments