First, the encapsulation of
Meaning: not visible to the outside, protection properties and methods are not seen by the external more
Implementation: Using the keyword Private declaration, the GET, set method for external access.
Delivery of the reference:
Static keyword: Cosmetic property (global property); Decoration method (called directly from the class name)
Only the properties and methods of the static declaration can be accessed in the static method.
can be instantiated before using Static:Person.setName ("name");//static method person P = new person ();
This keyword: Represents a property and method in a class, calls a constructor method in this class, and represents the current object.
Public people () {this ();//The constructor method that calls the default parameterless must have the first row this.name = name; this.age = age;}
Inner class: An object is automatically reclaimed by garbage from the new person (). tell ();
Second, the inheritance of
Meaning: Extending the functionality of a class
Implementation: Through the keyword extends. Limit: Only single inheritance is allowed.
Inheritance procedure constructs method call Order: Instantiate subclass Object-"Call parent class construction method first-" Call subclass constructor method
Override of Method: Subclass Overrides Parent class method
Subclass. Method () Only executes the contents of the subclass
Subclass. Method () {Super. method ()} Enforces methods of walking the parent class + subclasses of other
A quilt class overrides a method that cannot have more restrictive access than the parent class
Access rights: Private<default<public (Private, under the same package, the entire project)
Abstract class:
Abstract class: A class that contains an abstract method is an abstract class
Abstract method: Declaring a method that is not implemented, using the keyword abstract declaration
Abstract class classname{property; method; Abstraction Method}
An abstract class cannot be instantiated and instantiated through its subclasses. (All abstract methods must be implemented)
Interface:
Interface: is a special class that consists entirely of global variables and public abstract methods.
Interface interfacename{Global constant (public static final name); abstract method (public abstract void Name ())}
The implementation of the interface must be through subclasses, using implements, and interfaces can be implemented more. (All abstract methods must be implemented)
A class can inherit abstract classes and interfaces at the same time.
An interface cannot inherit an abstract class, but it can inherit multiple interfaces at the same time through the extends keyword. (Interface Intent3 extends intent1,intent2{})
Final keyword:
is called the end device, which means the final meaning. Can declare classes, methods, properties.
A class that uses final declaration cannot be inherited; A method that uses final declaration cannot be overridden; a constant declared with a final cannot be modified (name uppercase).
Iii. polymorphism
Meaning: Overloading of methods, polymorphism of objects.
The automatic completion of the parent class parent Class object = Subclass Example (parent Class). Method () to invoke a subclass of a replication method)
Transition-Forced type-Cast Subclass Subclass Object = (subclass) Parent Class example (first up and down)
Class A {tell1 ()}
Class B extends A {tell2 ()}
Class C extends A {tell3 ()}
Say (new B ()); Say (new C ());
Say (a a) {A.tell1 ()}
instanceof Keyword: Determines whether an object is actually an instance of a class.
A = new B (); A instanceof a true; A instanceof B true;
Overloads of the method:
Meaning: The method name is the same. But the parameter type and number are different. To complete the different functions.
Recursive call: Self tune yourself. Have to have an outlet ...
Three major features of Java