public class Stack {
private int size;
private int[] arr;
private int top;
public Stack(int size) {
this.size = size;
this.arr = new int[this.size];
this.top = -1;
}
public void push(int i) {
this.arr[++this.top] = i;
}
public int pop() {
return this.arr[this.top--];
}
public int peek() {
return this.arr[this.top];
}
public boolean isEmpty() {
return (this.top == -1);
}
public boolean isFull() {
return (this.top == this.size - 1);
}
}
For further actions, you may consider blocking this person and/or reporting abuse
Top comments (0)