Compiler Error J0189

'return' not allowed in a static initializer or instance initializer

A return statement was found in a static or instance initializer. Initializers, like constructors, can not return a value. Remove the return statement and compile again.

The following example illustrates this error:

public class Simple{
   
   static int var1;
   
   static{
      var1 = 0;
      return;
      //error: return statement not allowed in static initializer
   }
}