• Eclipse: Oxygen
  • Java: 1.8

It is a way to group many classes belonging to a specific project.  A package is like a folder of similar things such as music or a folder of movies.

The package adds a different level of inheritance, this level of inheritance is by default applied to all the members created in the method. Hence a package is a useful and efficient entity in java.  The package also has a naming convention which we have studied earlier. We can also import the packages which will result in accessing all the classes and methods in it.

The company uses always reversed Internet domain name for its package names. For example, the company’s Internet domain name is, and then all its package names start with org.studyeasy. Every component of the package name corresponds to a subdirectory.

In the following program, we have created two different packages. In both packages, we have created the same name classes. The import statement in Java allows you to refer to the classes that are declared in other packages that can be accessed without referring to the full name of the package.



There are two ways of import statement:

Here the import declaration is optional. If you want to use the class of a particular package, you can also use its full name, which includes its complete package hierarchy.




Contributed by: Poonam Tomar

Full stack Java Developer

   Buy me a coffee!



Download file

Leave a Reply

Notify of
Close Menu