Stack은 상자에 물건을 쌓아 올리듯이 데이터를 쌓는 자료구조이다. Stack은 나중에 들어간 것이 먼저 나오는 Last In First Out의 형태를 띈다.
Stack<Integer> stack1 = new Stack<>(); //int형
Stack<String> stack2 = new Stack<>(); //char형
Stack<Integer> stack = new Stack<>();
stack.push(1);
stack.push(2);
stack.push(3);
push()를 이용하여 값을 추가할 수 있다.
Stack<Integer> stack = new Stack<>();
stack.push(1);
stack.push(2);
stack.push(3); //값 추가
stack.pop(); //가장 마지막에 넣은 값을 제거
stack.clear(); //모든 값을 제거