title: Static reference to non-static field Java error
body: <p>I'll preface this by saying that I've been a longtime fan of Stack Overflow, and over the past few semesters I've usually been able to find the answer to all my questions without actually asking one. However, I've been having problems with a stack program. There's more code than this, but I think I've narrowed my problem down to this one error. It states</p>
  <blockquote>
  <p>Exception in thread &quot;main&quot; java.lang.Error: Unresolved compilation
  problems:</p>
  <blockquote>
  <p>Cannot make a static reference to the non-static field Stack1<br />
  The constructor Stack(int) is undefined</p>
  </blockquote>
  <p>at stack.main(stack.java:11)</p>
  </blockquote>
  <p>Can anyone explain what the issue might be? Or better yet, point me to somewhere that will explain it? I've tried looking it up on Overflow and through google, but I think a combination of not knowing what I'm actually looking for and/or fatigue is preventing me from finding a concrete answer. Thanks for any help in advance.</p>
  <pre><code>public class stack {
  private Object[] Stack1;
  private int topOfStack;
  private int max;
  //private int empty;
  //private int capacity;
  
  public static void main(String[] args) {
  Stack1 = new Stack(5);
      
  }
  
  public Stack(int size) {
      if (size &lt; 0){
          throw new IllegalArgumentException(&quot;Parameter must be &gt;0. Parameter was &quot; + size + &quot;.&quot;);
      }
      
      max = size; 
      Stack1 = (Object[]) (new Object[size]);
      topOfStack = -1;
  }
     }
  </code></pre>