Java Reference

Java Reference Home | Smart Soft Home

private

The keyword private has two uses: as a variable modifier and as a method modifier.

Description #1 - Variable Modifier

Indicates the visibility of a variable. A private visibility can only be accessed by methods in the same class.

Example #1 - Variable Modifier

private int x;

Description #2 - Method Modifier

Indicates the visibility of a method. A private method can only be invoked by other methods in the same class.

Example #2 - Method Modifier

private void calc(){
  ..
  ..
}