Skip to content

Commit 5b327c8

Browse files
feat t:Added Stack Implementation Using LinkedList
1 parent 1da26b4 commit 5b327c8

File tree

1 file changed

+0
-31
lines changed

1 file changed

+0
-31
lines changed

src/main/java/com/thealgorithms/stacks/StackUsingLinkedList.java

Lines changed: 0 additions & 31 deletions
Original file line numberDiff line numberDiff 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-
}

0 commit comments

Comments
 (0)