rootUser

STACK

Jul 9th, 2016
38
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 5 0.76 KB | None | 0 0
  1. package test;
  2.  
  3. import java.util.Stack;
  4.  
  5. public class Test
  6. {
  7.     public static void showpush(Stack<Integer> st,int a)
  8.     {
  9.         st.push(a);
  10.         System.out.println("push("+a+")");
  11.         System.out.println("stack : "+st);
  12.     }
  13.     public static void showpop(Stack<Integer> st)
  14.     {
  15.         System.out.println("Pop ->");
  16.         Integer a = st.pop();
  17.         System.out.println(a);
  18.         System.out.println("stack: "+st);
  19.        
  20.     }
  21.     public static void main(String[] args)
  22.     {
  23.         Stack<Integer> st = new Stack<Integer>();
  24.         System.out.println("stack : "+st);
  25.        
  26.         showpush(st,42);
  27.         showpush(st,66);
  28.         showpush(st,99);
  29.         showpop(st);
  30.         showpop(st);
  31.         showpop(st);
  32.     }
  33. }
Add Comment
Please, Sign In to add comment