safestack.java
来自「实例精华」· Java 代码 · 共 23 行
JAVA
23 行
public class SafeStack implements StackInterface{
private int top = 0;
private int[] values = new int[10];
public void push(int n) {
synchronized(this)
{
values[top] = n;
System.out.println("压入数字"+n+"步骤1完成");
top++;
System.out.println("压入数字完成");
}
}
public int[] pop() {
synchronized(this)
{
System.out.print("弹出");
top--;
int[] test = {values[top],top};
return test;
}
}
}
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?