컴퓨터 공부/JAVA

자바 - 스택, 큐 정리

seowon98 2020. 5. 23. 14:47

스택 - FILO
Stack stack = new Stack(); 

stack.push(0);

stack.push(1);

while(!stack.isEmpty()) System.our.print(stack.pop()); //1 0

 

큐 - FIFO

Queue q = new LinkedList();

q.offer(0);

q.offer(1);

while(!q.isEmpty()) System.out.prin(q.poll()); //0 1