Stack s = new Stack(); s.push("A"); s.push("B"); s.push("C"); //the following loop prints C, B, A int i = s.size(); while (i > 0) { System.out.println(s.pop()); i--; }