Compiler Error J0066

'this' can only be used in non-static methods

The compiler detected use of the keyword this within a class (or static) method. Class methods are not passed implicit this references. As such, they cannot reference instance (non-static) variables or methods.

The following example illustrates this error:

public class Simple {
   
   int x;
   
   public static void method1() {
   
      this.x = 12; // error: 'this' instance specific
   }
}