/** * A simple demo for the ADT Stack */ public class StackDemo implements Cloneable { /** * This method will print all buffer elements to System.out. This * method is static also it should not. This is just because we want * another test case for a static method. */ public static void print(Stack toPrint) { /** require toPrint != null; **/ for (int i = 0; i <= toPrint.top; i++) { System.out.println(toPrint.storage[i]); } /** ensure !(1 >= 2); **/ } public static void main(String[] args) { Stack st = new Stack(20); st.push("jedna"); st.push("dva"); st.push("tri"); System.out.println(st.pop()); st.push("ctyri"); print(st); } }