
데이터(data)를 순서대로 쌓는 후입선출 자료 구조
stack.get(index) : 특정 인덱스 원소 찾기stack.set(index,element) : 특정 인덱스에 원소 넣기stack.remove(index) : 특정 인덱스 원소 삭제💻 코드예시
Stack<Integer> stack = new Stack<>(); //Integer형 스택 선언
stack.push(1);
stack.push(2);
stack.push(3);
// 1 <- 2 <- 3
// 스택이 빌 때까지 데이터를 전부 뺀다
stack.pop();
stack.pop();
stack.pop();
// 3 -> 2 -> 1