1. Object-oriented (overview and role of the package keyword)
- A: Why should I have a bag
- Classify byte code (. Class)
- The package is actually a folder
- B: Overview of the Package
Example: Student: Add, delete, modify, query teacher: Add, delete, modify, inquire ...
方案1:按照功能分 com.heima.add AddStudent AddTeacher com.heima.delete DeleteStudent DeleteTeacher com.heima.update UpdateStudent UpdateTeacher com.heima.find FindStudent FindTeacher方案2:按照模块分 com.heima.teacher AddTeacher DeleteTeacher UpdateTeacher FindTeacher com.heima.student AddStudent DeleteStudent UpdateStudent FindStudent
2. Object-oriented (definition of package and matters needing attention)
- A: Define the format of the package
- Package name;
- Multi-stage ladle. Separate
- B: Considerations for defining packages
- The A:package statement must be the first executable code of the program
- The B:package statement can have only one in a Java file
- C: If there is no package, default means no packages name
- C: Case Demo
- Package Definition and Precautions
3. Object-oriented (class compile and run with package)
- A: How to compile a class that runs a package
- A:javac when compiling with-D
- B: Execute via Java command.
- The Java package name. Hellword
4. Object-oriented (access between classes under different packages)
- A: Case Demo
- Access between classes under different packages
5. Object-oriented (overview and use of the Import keyword)
- A: Case Demo
- Why should I have an import
- In fact, the class that has the package is visible to the caller without having to write the full class name.
- B: Guide Package format
- Import package name;
- Attention:
- This way the import is to the name of the class.
- Although it can be written last *, but not recommended.
- C:package,import,class there is no sequential relationship (interview question)
6, Object-oriented (four kinds of permission modifiers test)
7. Object-oriented (common modifiers used by the class and its composition)
8. Object-oriented (internal class overview and access Features)
- A: Internal class overview
- B: Internal class Access features
- A: The inner class can access the members of the external class directly, including the private.
- B: The external class must create an object to access the members of the inner class.
- The external class name. Internal class Name Object name = External Class object. Inner class object;
- C: Case Demo
- Internal class extremely accessible features
9. Object-oriented (private use of member inner Class)
10. Object-oriented (static member inner Class)
- Static
- B: The member inner class is accessed by statically modifying the following methods:
- The external class name. Internal class Name Object name = External class name. Inner class object;
11, Object-oriented (members of the internal class of interview questions)
12, Object-oriented (local internal class access to local variables of the problem)
A: Case Demo
- Local internal class access local variables must be final decorated
Local inner class in accessing the local variables in his method must be final decorated, why? Because when this method is called, if the local variable is not final decorated, his life cycle and method life cycle is the same, when the method of the stack, the local variable will disappear, then if the local inner class object has not disappeared immediately want to use this local variable, there is no, If the final decoration will enter the constant pool when the class loads, even if the method is stacked, the constant pool constant is still there, you can continue to use
But jdk1.8 canceled this thing, so I think it's a bug.
13. Object-oriented (the format and understanding of anonymous inner classes)
- A: Anonymous Inner class
- is the simplified notation of the inner class.
- B: Premise: There is a class or interface
- The class here can be either a concrete class or an abstract class.
- C: Format:
new 类名或者接口名(){ 重写方法;}
- D: What is the essence?
- is an anonymous object that inherits the class or implements the interface's subclass.
- E: Case Demo
- An anonymous inner class as required
14. Object-Oriented (anonymous inner class overrides multiple method calls)
- A: Case Demo
- Method invocation for Anonymous inner class
15, Object-oriented (anonymous internal class in the development of the application)
16, Object-oriented (anonymous internal class interview questions)
Java EE Basics (10)