栈是先进后出,连续入栈出栈两次,就是先进先出,如同队列 import java.util.Stack;

public class Solution { Stack stack1 = new Stack(); Stack stack2 = new Stack();

public void push(int node) {
    stack1.push(node);
}

public int pop() {
 if(stack2.isEmpty()){   //判断栈2,是否为空,空可以放心放数据
     while(!stack1.isEmpty()){  //一致出栈1,然后入栈2
         stack2.push(stack1.pop());
     }
 }

       return stack2.pop();

}

}