728x90 반응형 Stack2 [20.07.29/Day_15] Java SE / Collection 컬렉션(stack 스택, Queue 큐) , Exception(try, catch, finally | throws, throw) [ Stack 스택 / Queue 큐 ] java.util.collection stack : (LIFO) last-in-first-out 마지막에 추가된 요소가 먼저 추출되는 자료구조 : pop()메서드를 이용하면, 추출되며 사라짐. stack 예제 import java.util.Stack; public class TestStack { public static void main(String[] args) { Stack stack = new Stack(); // 축적 메서드 : push(value) stack.push("a"); stack.push("b"); stack.push("c"); stack.push("d"); stack.push("e"); System.out.println(stack); // [a.. 2020. 7. 29. CODE [20.07.29/Day_15] Java SE / Stack과 Queue, Exception(Exception(try, catch, finally | throws, throw) [ Stack ] empty() 메서드를 이용하여, 모든 요소 추출 /TestStack.java import java.util.Stack; public class TestStack { public static void main(String[] args) { Stack stack = new Stack(); // 축적 메서드 : push(value) stack.push("a"); stack.push("b"); stack.push("c"); stack.push("d"); stack.push("e"); System.out.println(stack); // [a, b, c, d, e] // 요소 유무 확인 메서드 :empty() // 요소 있으면 False, 비어있으면 True System.out.println(.. 2020. 7. 29. 이전 1 다음 728x90 반응형