Create Sub Packages in Java   | Java Online Training

This Java Online Training “Create Sub Packages in Java” page is providing clearly how to create packages and sub packages in java and how to access classes of sub packages in java application.


Creation of Sub packages :

  • Using “package” keyword, we can create sub packages.


Syntax :

package parent_package.child_package ;

Example :

package java.operators ;
package java.operators.arithmetic ;


Note: In the process of sub package creation, the required directories to generate the class file will be created implicitly by the Compiler.




Import Sub packages:

  • By importing Parent package, we cannot access Child package classes.
  • We must import Child package explicitly to access Child package classes.

import sub packages in Java

Share this