Since I have recently learned Java, I have encountered some concepts that are not available in C++. I will record them and review them for myself. If there is any inappropriate understanding, I hope everyone will criticize and guide them. All the information is integrated and understood online by yourself. If there is any infringement, please notify me to delete it.
I'll start with package and import.
The role of package is actually the role of c++ namespace to prevent conflicts between classes with the same name, but the implementation mechanism is different. When compiling, the java compiler directly generates the generated class file to the corresponding directory based on the information specified by package. For example, the package aaa.bbb.ccc compiler generates various classes in the .java file into the directory ./aaa/bbb/ccc/.
With the package mechanism, it is very troublesome to use different classes (referring to writing longer when writing code), so the Great God Sect came up with a way to be lazy, so the import mechanism was found. Suppose that Class A under ./aaa/bbb/ccc/, if there is no import mechanism, how do we need to instantiate Class A? New aaa.bbb.ccc.A(), and after using import aaa.bbb.ccc.A, we can directly use new A(), that is, the compiler helps us match and extend aaa.bbb.ccc. This string is just related to the compilation speed, but it is not a particularly large project, so it can definitely be ignored.
The above brief analysis of package and import of the package and import of the introductory concept of java is all the content I share with you. I hope you can give you a reference and I hope you can support Wulin.com more.