CodePudding user response:
Public class LimitQueue {
Private int [] array;
Private int size;
private int index;
Public LimitQueue (int size) {
Array=new int [size];
This. Size=size;
Enclosing the index=1;
}
Public void push (int value) {
If (index & lt; The size 1) {
Index++;
Array [index]=value;
} else {
System. The out. Println (" array is full ");
}
}
Public int the pop () {
If (index & gt;=0) {
The int value=https://bbs.csdn.net/topics/array [index];
The index -;
System. The out. Println (" array pop-up element: "+ value);
return value;
} else {
System. The out. Println (" array can pop-up element ");
return 0;
}
}
}