non-static variable x cannot be referenced from a static context
<p>Excuse my ignorance. I'm a beginner:</p>

<p>Why is the following code giving me the following compiling error?
[line: 16] non-static variable x cannot be referenced from a static context</p>

<pre><code>public class average{
int [] numbers = {2,3,4,5,6};
double x = averageMark(numbers);

public static double averageMark(int [] numbers){
    int sum = 0;  
    double average = 0.000;
    for (int i = 0; i &lt; numbers.length; i++){  
      sum = numbers [i] + sum;  
      average = sum/numbers.length;  
    }
    return average;
  }

  public static void main (String [] args){
  System.out.println(x);
  }
}
</code></pre>
