Http://www.runoob.com/java/java-package.html
The role of the package:
1. Organize similar or related classes or interfaces in the same package to facilitate the search and use of classes.
2. Like folders, packages are stored in a tree-like directory. The class names in the same package are different, and the class names in different packages can be the same.
When a class with the same name is called, the package name should be added, and the package can avoid name collisions.
3. The package also has access to a class that has access to the package to access it.
Java uses the package as a mechanism to prevent naming conflicts, access control, and to provide search and location classes, interfaces, enumerations, and annotations.
Package Net.java.util; Public class something{... }
Its path is saved by Net/java/util/something.java.
The following are the packages in Java:
Java.lang--The class of packaging basics
Java.io--functions with input and output functions
To create a package:
The package declaration should be in the first line of the source file, and each source file can have only one package declaration, and each of the types in the file is applied to it.
If a package declaration is not used in a source file, then the classes, functions, enumerations, comments, and so on will be placed in a nameless package (unamed).
Import Keyword:
In order to be able to use the members of a package, we need to explicitly import the package in a Java program.
In the Java source file, the import statement should be located after the package statement, and before all classes are defined, there can be no or more than one.
There are several ways to implement classes that are introduced into other packages:
1. Otherpackage.otherclass in the Code
2.import otherpackage.*;
3.import Otherpackage.otherclass;
Note: The class file can contain any number of import declarations. The import declaration must precede the class declaration after the package Declaration.
Java Tour _ Object-oriented _ package