I have created a stack .
public class STK {
    static int capacity = 0; 
    STK(int size) {
        capacity = size;
    }
    int stackk[] = new int[capacity];
    int top = 0;
    public void push(int d) {
        if(top < capacity) {
            stackk[top] = d;
            top++;
        } else {
            System.out.println("Overflow");
        }
    } 
}
its implementation
public class BasicStackImplementation {
    public static void main(String[] args) {
        STK mystack = new STK(5);
        mystack.push(51);
        mystack.push(23);
    }
}
when i try to run this code it gives an error
Exception in thread "main" java.lang.ArrayIndexOutOfBoundsException: 0
    at STK.push(STK.java:21)
    at BasicStackImplementation.main(BasicStackImplementation.java:6)
 
     
     
    