Java Packages

What is a Package?

Package is nothing but a directory which is containing classes and sub packages (sub directories). In other words package is a set of classes grouped together. You can specify the package using a package declaration package < package-name > as the first (non-comment) line in the class.

Why to use Package?

To group the classes.

What are Java Package Advantages?

  1. To group the classes.
  2. To restrict the accessibility of classes.
  3. Easy pluggability of modules.
  4. Reusabilty of modules.

In this tutorial you can learn about the following java packages.