자바 - StackQueue

|
import java.util.LinkedList;
import java.util.Queue;
import java.util.Stack;


public class StackQueueEx {
	public static void main(String arg[]) {
		Stack st = new Stack();
		Queue q = new LinkedList();
		
		st.push(0);
		st.push(1);
		st.push(2);
		
		q.offer(0);
		q.offer(1);
		q.offer(2);
		
		System.out.println("==Stack==");
		while(!st.empty()) {
			System.out.println(st.pop());
		}
		System.out.println("==Queue==");
		while(!q.isEmpty()) {
			System.out.println(q.poll());
		}
	}
}

'Programming > 강의' 카테고리의 다른 글

자바 - Iterator ListIterator  (0) 2014.07.28
And