Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import java.util.*;
- class stackdemo {
- public static Stack<Integer> S = new Stack<Integer>();
- public static void main(String[] args) {
- int temp;
- S.push(3);
- S.push(4);
- S.push(1);
- S.push(10);
- S.push(20);
- S.push(30);
- System.out.println("1st element poped from the stack:");
- temp = S.pop();
- System.out.println(temp);
- System.out.println("2nd element poped from the stack:");
- temp = S.pop();
- System.out.println(temp);
- System.out.println("Remaining elements");
- while (!S.empty()) {
- System.out.println(S.pop());
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement