Regaining the Basics of Java (10): Summary of the Concept of Packages
1. The Concept of Packages
1. A package refers to a folder created during Java compilation in order to distinguish the subdivisions of each module in Java.
2. The package is usually filled with bytecode files (.class) generated after compiling the class.
3. The naming of the package is usually the company domain name. Project name. Module name ( com.taobao.denglu.*)
2. Create a package
1. Creating a package is generally created starting from the current folder.
2. Create a package using the package name.
3. If you do this: package cn.aa.bb Then create the cn folder starting from the current folder. The cn folder includes the aa folder. The aa folder includes the bb folder.
4. Create a package: It is not recommended to create a folder directly on the hard disk and compile javac -d TestPackage.java with the package (you can also write the path after -d, so that it will be built in the path you specified)
5. Run with package: Class name of the class with package: package name. Class name abc.TestPackage Full name of class name
6. Must comply with identifier regulations and cannot start with a dot Or end
7. See the name and know the meaning a.b.c
3. Import package
#1. The import package is a certain one in java package to call classes and methods in another package. At this time, you must import the package path of the class you want to call.
2. Use the import keyword to import packages. But please note that the paths are connected with (dots in English).
3. import package name.class name
;4. Sequence: Declare package>Import package>Definition class
4. Visit the decoration
# 1, decorative category:
A, PUBLIC Unlimited Import Import, you can use
#ser Can be called * Public2 is generally used in front of the class. Modification method. Use C, default modifier package permissions D, private class permissions
#6. Local classes
Local variables: variables defined in a method
3. The scope of use of a local inner class is the same as that of a local variable
##7. Anonymous inner classes (key points)
2. Internal class without name
The above is to regain the basics of java (10) : Summary of the concept of packages. For more related content, please pay attention to the PHP Chinese website (www.php.cn)!