fork download
  1.  
  2. import java.io.*;
  3. import java.util.*;
  4.  
  5. class Test{
  6. public static void main(String args[]){
  7. Stack stack = new Stack();
  8.  
  9. // push
  10. for( int i = 0 ; i < 5 ; i++ ){
  11. Integer integer = new Integer(i);
  12. stack.push(integer);
  13. System.out.println( "push : " + integer );
  14. }
  15.  
  16. // 改行
  17. System.out.println();
  18.  
  19. // pop
  20. while( !stack.empty() )
  21. System.out.println( "pop : " + stack.pop() );
  22. }
  23. }
  24.  
  25.  
Success #stdin #stdout 0.07s 380224KB
stdin
Standard input is empty
stdout
push : 0
push : 1
push : 2
push : 3
push : 4

pop : 4
pop : 3
pop : 2
pop : 1
pop : 0