One.
When it comes to finding out, there is not a package, the source of the writing class name to write very long (class name prefix package is many). Class file hierarchy is too many, too many packages, it seems very troublesome.
If you don't want to write such a long name, we have some solutions. We can do this with a keyword so that you can achieve the same functionality.
is to import Demoa package, I think the import means that the location from the other package belongs to the location of the package. This is more convenient to use.
If there are other classes in other packages to use, continue to import them.
Some people say, this is very troublesome, can use simple method, is a wildcard character. All the symbols that match.
Use * to replace all.
Now in the Packa package, the same level has both packages and class files. Now ask, if write import packa.*, can build Demoabc class object?
The answer is no, import imports the classes in the package and does not import the packages in the package. In this way, the sub-package ABC can not be imported, the inside of the demoabc.class can not be imported.
To import the class file of the package in the package, you can write it as follows,
It is not recommended to write the * number when really developing. Because the class file is much more, it is not possible to import all.
The principle of the guide package, which class to use, and which class to import.
So if you use dozens of classes, do you want to import dozens of imports? Yes.
Advanced compiler, without you writing import, a key, it automatically imports all. Hundreds of lines of import statement, it automatically help you to complete. Even if the package does not write, it will automatically help you complete. These are fixed codes that are generated automatically.
There can be only one package in a. java file, but there may be more than one import.
We do not guide the package, the class in the package.
Java-Preliminary Understanding-12th-Object oriented (import imported)