Compiler Error J0147

Cannot access private member 'identifier' in class 'identifier' from class 'identifier'

The compiler detected an invalid attempt to access a private member contained within another class. Private class members are only accessible from within the member's class. A class’s private members are also available from its inner classes.

The following example illustrates this error:

class AccessClass {
   
   private int i = 0;
   
}

public class Simple {
   
   public void method1() {
      
      AccessClass ac = new AccessClass();
      
      ac.i = 1;
      // error: cannot access 'i'
   }
}