Packages
suggest changeVersions
Packages have been in the language since Java 1.0.
Introduction
A package in Java is used to group classes and interfaces. This helps developers avoid name conflicts when there are many classes. Classes and interfaces in different packages can have the same simple name.
Another class can import a type from a package.
There are many built-in packages in Java, such as
java.utiljava.langjava.io
We can define our own user-defined packages.
Remarks
Packages provide access protection.
The package declaration must be the first statement in the source file. Comments may precede it, and a source file has at most one package declaration.
Packages can also avoid name conflicts between different parts of a program.
Found a mistake? Have a question or improvement idea?
Let me know.
Table Of Contents