title: Cannot make a static reference to the non-static method fxn(int) from the type Two
body: <blockquote>
    <p><strong>Possible Duplicate:</strong><br>
    <a href="https://stackoverflow.com/questions/290884/what-is-the-reason-behind-non-static-method-cannot-be-referenced-from-a-static">What is the reason behind &ldquo;non-static method cannot be referenced from a static context&rdquo;?</a><br>
    <a href="https://stackoverflow.com/questions/4969171/cannot-make-a-static-reference-to-the-non-static-method">Cannot make a static reference to the non-static method</a><br>
    <a href="https://stackoverflow.com/questions/8101585/cannot-make-a-static-reference-to-the-non-static-field">cannot make a static reference to the non-static field</a>  </p>
  </blockquote>
  
  
  
  <p>I am not able to understand what is wrong with my code.</p>
  
  <pre><code>class Two {
      public static void main(String[] args) {
          int x = 0;
  
          System.out.println("x = " + x);
          x = fxn(x);
          System.out.println("x = " + x);
      }
  
      int fxn(int y) {
          y = 5;
          return y;
      }
  }
  </code></pre>
  
  <p>Exception in thread "main" java.lang.Error: Unresolved compilation problem: 
  Cannot make a static reference to the non-static method fxn(int) from the type Two</p>