1. Package
1) Package: Packages The class, while restricting access rights
2) package creation, package + Pack name (package name usually by domain name + specific name) such as:
Package Com.baidu; Public class Person {}
This code is implemented to package person into Com/baidu, where registration is the domain name + specific name; Here the full name of this class is Com.baidu.person.
3) The import of the package, using the Import + package name. The class name is imported, such as:
Import Pack.person; Public class Test { publicstaticvoid Main (String args []) { }}
In this way, the member variables and member functions in the person class can be used in the test class.
2. Access rights
1) There are four types of access rights, as follows:
Public // in common, any class in any package can be accessed default // Default (default is not written), can only be accessed in the same package protected // protected, the same package can be accessed, while subclasses can be accessed (including subclasses in different packages) Private // private, only this class can access
2) When a class is defined as public, the name of the class must be the same as the file name.
Java4android Basic Learning Package and access rights