public class MyStack {
private long[] arr;
private int top;
public static void main(String[] args) {
MyStack ms = new MyStack(4);
ms.push(23);
ms.push(12);
ms.push(90);
ms.push(83);
System.out.println(ms.isFull());
System.out.println(ms.isEmpty());
System.out.println(ms.peek());
System.out.println(ms.peek());
while(!ms.isEmpty()){
System.out.print(ms.pop() + ",");
}
System.out.println();
System.out.println(ms.isEmpty());
System.out.println(ms.isFull());
}
public MyStack(int maxsize){
arr = new long [maxsize];
top = -1;
}
public void push (int value){
arr[++top] = value;
}
public long pop(){
return arr[top--];
}
public long peek(){
return arr[top];
}
public boolean isEmpty(){
return top == -1;
}
public boolean isFull(){
return top == arr.length - 1;
}
}