A package is a mechanism for classifying java classes together.
If there are a large number of classes, it will be easier to manage the classes that are grouped together by classifying them by function.
By declaring (package) at the beginning of a class, you can specify the package to which the class is classified.
package pack;
If no package is specified, it will be classified as the default package.
If you specify a package, the source files for that class must be stored in a folder with the same name as the specified package.
If you move the file, you need to change the package declaration in the source as well.
Classes in the same package can be accessed only by the class name.
However, if you want to access a class outside the package, you need to specify the location of the target class with an import statement.
import pack;
The package can create layers. For packages consisting of multiple layers, concatenate the package names in order from the top of the layers with (.).
package packA.packB.packC;
Recommended Posts