import java.util.Stack;

public class Solution {

Stack<Integer> stack1 = new Stack<Integer>();
Stack<Integer> stack2 = new Stack<Integer>();

public void push(int node) {
    stack1.push(node);//直接入栈
}

public int pop() {
    if(!stack2.isEmpty()) //如果栈2不为空
        return stack2.pop(); //则直接弹出栈顶元素
    else{
        /*
            如果栈2为空,则要将栈1所有元素都移到栈2,最后弹出栈顶元素即可
        */
        while(!stack1.isEmpty()){ 
            stack2.push(stack1.pop());
        }
        return stack2.pop();
    }
}

}