############### day08 Eclipse using #####################
alt+/Auto-complement full SYSO
SHIFT + ENTER to the beginning of the next line
Ctrl+shift+f Formatting Code
ctrl+/Single-line comment
ctrl+shift+/Multi-line comments
Ctrl+shift+o Guide Bag
ALT + up and down arrows move lines of code
Ctrl+d Delete
Ctrl+1 Opinion Tips
Import Project
############## day09 class Day10 inheritance ##########################
Local variables do not have default values, follow methods into the stack
member variables and class objects enter the heap
Private modifier member variable, this class is visible
The nearest access principle for class methods
THIS.name with C + + the This pointer
P.speak () at the time of invocation, pass the address to this
Extends Java single inheritance
Subclass call member variable, method, name with nearest principle
You can also use This,super to indicate that this class and the parent class
Implements implements the interface, all methods must be overridden
Override Overrides
The permissions of a subclass method are greater than or equal to the parent class method
Public
Protected can be used in different package subclasses
Default is used within this package, no permissions are written
Private
Public abstract class Abstract classes, cannot instantiate objects
public abstract void work (); Abstract methods must exist in abstract classes
As long as there is an abstract method, it must be an abstract class
Abstract classes can have no abstract methods
Subclasses must override parent class abstract methods
################### Day11 Interface ##################
Interface member method full abstract, member variable is constant
Public abstract return value type method name (parameter list) # member method must be this format
public static final int a = 1;
# can not write modifier, selective write modifier, but the essence is the same
Multiple interfaces can be implemented, but multiple interfaces cannot have the same (function name, parameter list) return value different
Interfaces can extends other interfaces
polymorphic FU f = new ZI () parent class (interface) reference to child class object
Automatic type promotion appears, subclass promoted to parent class type, upward transition
You can only call methods that are common to a parent child, and you cannot call a method specific to subclasses
ZI z = (ZI) F down transformation
#多态
member variables, static member methods
Compile to see the parent class
Run See Parent class
F.A call is a member of the parent class variable, if none, error
Non-static Member methods
When compiling, look at the parent class
Look at the sub-class when running
instanceof determine if a reference variable is a class object
P instanceof People
########### Day12 Construction method, this, super ##########
Constructor method format permission class name (argument list) and C + +, default has no parameter constructor method rules, with C + +
This (parameter list) calls another constructor in one constructor and must be written in the first row of the constructor
Parameter list should match argument list of corresponding constructor
Super (parameter list) call the parent class constructor in the subclass constructor, the argument list can be empty (call null argument)
The constructor method in the subclass automatically calls the parent class's parameterless construction method (if the parent class constructor method is not shown)
First line
Super. Calling a member function of a parent class with a member variable
Super (), this () cannot appear at the same time
The subclass memory space is divided into the parent class space and the subclass space, with C + +
All constructors of subclasses have to call the parent class constructor directly and indirectly
########### DAY13 Final Static anonymous object inner class package ########
# final
Modifier class, cannot be inherited
Modified method, cannot be overridden
modifier variables, one assignment at a time, cannot be changed, with C + + const
Modify the reference data type, the memory address stored by the variable cannot be changed with C + + const
Modifying member variables
Assignment of member variables, assigning values before objects are created
1, final int age= 1; Direct Assignment (recommend)
2, the construction method assigns the value
final int age;
Public People (int.)
{
This.age = age;
}
# static with C + +
Decorates a class member, becomes an object to share data, does not belong to an object, a class common, and C + +
Can be called with the class name, exists in the static zone, has a default value
public static final String school_name = "Itcast";
Constant capitalization, underlined between words
Anonymous object: Do the parameters, do the return value
Inner classes can use external class members
External class to use members of an inner class, you must establish an inner class object
Invoke Rule
The external class name. internal class Name variable = new external Class (). New inner Class ();
Variables. Internal class Members
A call to a variable of the same name
Call external class member outer.this.i;
Call internal class member this.i;
Call local variable i;
Local inner class
Create an inner class object inside the method, and the object is called
# Anonymous Inner class
Define the implementation class, override the method, and create the implementation class object in one step
New interface/Parent class () {
overriding abstract methods
}. method;
Polymorphic Way
interface/Parent class variable = new interface/parent class () {
overriding abstract methods
};
Variables. Method 1;
Variables. Method 2;
Class XXX implements smoking{new smoking () {
public void smoking () is equivalent to public void smoking ()
{} { }
}}.smoking ();
xxx x = new xxx ();
X.smoking ();
Package is equivalent to folder package name URL back write
Code block Execution Order
Static code block, executed only once
Building code Blocks
Construction method
Java Learning Diary (8-13)