Web Programming/Java

[BASIC JAVA] 20.STACK_QUERE_TEST

JEONGGI 2021. 6. 20. 02:18
Stack<String> st = new Stack<>();                                                                
                                                                                                 
st.push("0");                                                                                    
st.push("1");                                                                                    
st.push("2");                                                                                    
                                                                                                 
while (!st.empty()) {                                                                            
	System.out.println(st.pop());                                                                
}                                                                                                
                                                                                                 
                                                                                                 
System.out.println("========================================================");  
                                                                                                 
Queue<String> qu = new LinkedList<>();                                                           
qu.offer("0");                                                                                   
qu.offer("1");                                                                                   
qu.offer("2");                                                                                   
                                                                                                 
while (!qu.isEmpty()) {                                                                          
	System.out.println(qu.poll());                                                               
	                                                                                             
}