Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
一旦数据弹出,我想从堆栈顶部永久删除数据
返回堆栈[顶部--]!
但是当我再次调用弹出时,我得到的值与上次弹出的值相同!那么一旦弹出任何提示,如何删除数据!
提前谢谢(需要使用java代码的提示)
public static void main(String args[]) { Stack stack = new Stack(); for (int i = 1; i <= 10; i++) stack.push(new Integer(i)); while (!stack.empty()) System.out.print(stack.pop() + " "); System.out.println(" No element in stack"); }
这对我来说很好。