1 package spoon.examples.stack.src; 2 3 import java.util.List ; 4 import java.util.Vector ; 5 6 import spoon.examples.stack.annotation.Bound; 7 8 12 @Bound(max = 5) 13 public class Stack<T> { 14 15 List <T> elements = new Vector <T>(); 16 17 public void push(T element) { 18 elements.add(0, element); 19 } 20 21 public T pop() { 22 return elements.remove(0); 23 } 24 25 public static void main(String [] args) { 26 try { 27 Stack<Stack> s = new Stack<Stack>(); 28 s.push(s); 29 System.out.print("."); 30 s.push(s); 31 System.out.print("."); 32 s.push(s); 33 System.out.print("."); 34 s.push(s); 35 System.out.print("."); 36 s.push(s); 37 System.out.print("."); 38 s.push(s); 39 System.out.print("."); 40 s.push(s); 41 System.out.print("."); 42 } catch (Exception e) { 43 System.out.flush(); 44 System.err.println("Exception " + e.getClass().getSimpleName()); 45 } 46 } 47 } 48 | Popular Tags |