-------<a href= "http://www.itheima.com" target= "blank" >android training </a> <a href= "/http/ Www.itheima.com "target=" blank ">java training </a>, look forward to communicating with you! ----------
A. Package:
1. Define Package usage keywords: packages;
1). Precautions:
The A.package statement must be the first executable code of the Java source program
The B.package statement can have only one in a Java file
C. If there is no package, default means no packages name
2. Import package using keywords: import;
1). Precautions:
A. Import into the final class;
B. Wildcard characters can be used: *, only the class under the package, not including other classes under the sub-package;
C. In a class file, you can have more than one import statement;
The D.import statement must precede the package statement before the class is defined;
3.package,import,class have a sequential relationship?
There are: Package-->import-->class
Two. Access modifiers:
1. To qualify "class" and "member" to be accessed by other classes under other packages;
2. Four access modifiers:
1). Public: You can decorate classes, members. can be accessed by any other class under any package;
2). protected (Protection): Members can be decorated. can be accessed by other classes under the same package. If only the quilt class access outside the package;
3). (default): Class, member can be decorated. can only be accessed by other classes within the package;
4). Private (private): Members can be decorated. can only be accessed by other methods in the class;
3. Modifiers available for classes and members:
1). Class: (default), public,final,abstract our own definition: public mostly
2). Member variables: Four permission modifiers are available, final,static we define: private majority
3). Construction method: Four kinds of permission modifiers are available, others can not be defined by us: public majority
4). Member Method: Four permission modifiers are available, fianl,static,abstract we define: public mostly
Three. Inner class:
1. member Inner class:
1). defined in the class body, as a member of the class;
2). You can use the same modifier as the "member method" of the same class;
2. Local Inner class:
1). Defined within a method or block of code;
2). You cannot use the "access modifier", you cannot use the static modifier; You can use the final and abstract
3). Note: Local internal classes access "local variables", requiring local variables to be final (constants);
Class a{
public void Show () {
int num = 10;//This variable requirement must be: final
Class b{
public void Method () {
SYSTEM.OUT.PRINTLN ("num =" + num);//Compilation error
}
}
}
}
3. Anonymous inner class:
1). is a simplified notation of the inner class.
2). Premise: There is a class or interface here the class can be either a concrete class or an abstract class.
3). Format: New class name or interface name () {override method;}
4). Nature: A subclass of anonymous objects that inherit a class or implement an interface
-------<a href= "http://www.itheima.com" target= "blank" >android training </a> <a href= "/http/ Www.itheima.com "target=" blank ">java training </a>, look forward to communicating with you! ----------
Dark Horse Programmer _ Package, access modifier, and inner class