?? stack.java
字號:
public class Stack<T> {
public StackNode<T> stackTop;
public int count;
public void push(T info) {
StackNode<T> node = new StackNode<T>();
node.info = info;
node.link = stackTop;
stackTop = node;
count++;
}
public void pop() {
if(stackTop == null) {
System.out.println("null stack");
} else {
stackTop = stackTop.link;
count--;
}
}
public boolean isEmpty() {
return count == 0;
}
public T top() {
if(stackTop == null) {
return null;
}
return stackTop.info;
}
public String toString(){
Stack<T> other = new Stack<T>();
while(count != 0){
T top = top();
pop();
other.push(top);
}
StringBuffer buf = new StringBuffer();
while(other.count !=0){
buf.append(other.top());
other.pop();
}
return buf.toString();
}
}
?? 快捷鍵說明
復(fù)制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -