Compiler Error J0060

Invalid forward reference to member 'identifier'

The compiler detected an attempt to initialize a variable with another variable that had not yet been defined. To avoid this situation, reverse the field declarations order so that a variable that is referenced by another is defined first.

The following example illustrates this error:

public class Simple {
   private static int i = j; 
   // error: 'j' not yet defined
   private static int j = 0;
}

The following shows the correct way to initialize a field using another field in the same class:

public class Simple{
   private static int j = 0; //field is instantiated and populated
   private static int i = j; //with 'j' properly set, 'i' can be set
}