📄 stack.java
字号:
/*
* Created on 2004-12-2
*
* TODO To change the template for this generated file go to
* Window - Preferences - Java - Code Style - Code Templates
*/
package calculator;
public class Stack
{ private Node top;
public Stack()
{ top = null; }
public void push(Object obj)
{ Node node = new Node(obj);
node.next = top;
top = node;
}
public Object pop() throws StackException
{ if (top == null)
throw new StackException("popping from an empty stack");
else
{ Object obj = top.data;
top = top.next;
return obj;
}
}
public Object peek() throws StackException
{ if (top == null)
throw new StackException("peeking into empty stack");
else
return top.data;
}
public boolean isEmpty()
{ return (top == null); }
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -