Stack Implementation in Java : <p>I'm trying to implement a stack using Arrays in Java. My Stack class consists of non static methods push, pop, peek and isempty. I want to test the stack implementation be instantiating the stack in a non static main method within a main class. When I try to do that I get an error <strong>"non-static method push(int) cannot be referenced from a static context"</strong>
What am I doing wrong ?</p>

<p>Stack.java</p>

<pre><code>public class Stack {

private int top;
private int[] storage;

Stack(int capacity){
    if (capacity &lt;= 0){
        throw new IllegalArgumentException(
                "Stack's capacity must be positive");
    }
    storage = new int[capacity];
    top = -1;
}

void push(int value){
    if (top == storage.length)
        throw new EmptyStackException();
    top++;
    storage[top] = value;
}

int peek(){
    if (top == -1)
        throw new EmptyStackException();
    return storage[top];
}

int pop(){
    if (top == -1)
        throw new EmptyStackException();
    return storage[top];
  }
}
</code></pre>

<p>Main.java</p>

<pre><code>public class Main {

public static void main(String[] args) {
    new Stack(5);
    Stack.push(5);
    System.out.println(Stack.pop());

 }
}
</code></pre>
