import java.util.*;
// Java Collection Framework of Stack
class StackB {
public static void main(String[] args) {
Stack<Integer> s = new Stack<>();
s.push(1);
s.push(2);
s.push(3);
System.out.println(s); // Before pop
while(!s.isEmpty()) {
System.out.println(s.peek());
s.pop();
}
System.out.println(s); // After pop
}
}
No comments:
Post a Comment