# public Java Keyword

The public keyword is an access control modifier that may be applied to a class, a method or a field (a variable declared in a class).

## Examples

      public class MyPublicClass
      {
         public class MyPrivateClass
         {
         }

         public int i;

         public String myMethod()
         {
           <statements>
         }
      }

## Remarks

- A public class, method or field may only be referenced from any other class or package.

- The default access for all class members is package access, meaning that unless a specific access control modifier is present the class members are accessible from within any class in the same package.

Related Topics

private Java Keyword

protected Java Keyword