import java.util.Stack; //将stack1用作加入队列操作,stack2用作出队列操作 //每次入队之前,判断stack2是否为空,若不为空,将stack2出栈加入stack1 //然后再入栈 //每次出队列之前,判断stack1是否为空,若不为空,将stack1出栈加入stack2 //然后再出队列 public class Solution { Stack stack1 = new Stack(); Stack stack2 = new Stack();

public void push(int node) {
        while(!stack2.isEmpty()){
            stack1.push(stack2.pop());
        }
    stack1.push(node);
    
}

public int pop() {
     while(!stack1.isEmpty()){
            stack2.push(stack1.pop());
        }
    return stack2.pop();

}

}