The default access mode (no modifier) : default modifier « Modifiers « SCJP






Default accessor occurs when public, protected, or private are not specified. 

Default accessor applies to classes, interfaces, variables, methods, and constructors. 

Default accessor allows the declared item to be accessed by any class or interface of the same package.


Default and protected members differ only when subclasses are involved
   Default members can be accessed only by classes in the same package.
   protected members can be accessed by other classes in the same package, plus subclasses regardless of package.
   protected = package + subclass kids.

package certification;
public class OtherClass {
  void testIt() {   // No modifier means method has default access
    System.out.println("OtherClass");
  }
}

In another source code file you have the following:

package somethingElse;
import certification.OtherClass;
class AccessClass {
  static public void main(String[] args) {
    OtherClass o = new OtherClass();
    o.testIt();
  }
}








3.3.default modifier
3.3.1.The default access mode (no modifier)
3.3.2.The following declarations are illegal for default modifier
3.3.3.Default is the name for empty modifier.
3.3.4.Default modifier for method