A private method is a method which is not inherited by subclasses.

Declaring a method private defines its access level. The other options for declaring visibility are public and protected. If undeclared, the default access level is package.

The privateMethod() method is a private method in the following class:

 public class MyClass {

    private void privateMethod() {
        System.out.println("I am private method");

    void packageMethod() { 
        System.out.println("I am package method");

    protected void protectedMethod() {
        System.out.println("I am protected method");

    public void publicMethod() {
        System.out.println("I am public method");