
class Stack {
int idx = 0; // 堆栈指针的初始值为0
char[] data = new char[6]; // 堆栈有6个字符的空间
public void push(char c) {
synchronized (this) { // this表示Stack的当前对象
data[idx] = c;
idx++;
}
}
public char pop() {
synchronized (this) { // this表示Stack的当前对象
idx--;
return data[idx];
}
}
}



