public class UseStack{
	public static void main(String[] args) {

		Stack stk = new Stack(15);
		Stack.StepThrough iterator = stk.new StepThrough();

		System.out.print("\nPopulate Stack:\t\t");
		for (int j = 0 ; j < 10 ; j++) {
			stk.push(2*j);
			System.out.print(2*j + " ");
		}

		System.out.print("\nIterate Through Stack:\t");
		while (!iterator.isLast()) {
			System.out.print(iterator.current() + " ");
			iterator.increment();
		}
		System.out.print(iterator.current() + " ");

		System.out.print("\nDepopulate Stack:\t");
		while (stk.getSize() > 0) {
			System.out.print(stk.pop() + " ");
		}
	}
}