1. How to construct a method: Create a new object using the new+ construction method
When creating objects, execute the construction method
Create object process can directly create simultaneous assignment of initial value
Static variables are used in 2.Java: In order for all members of the class to share a member:
1 Public class helloword{23publicstaticvoid main (string[] args) { 4 // write code that is equivalent to the main function in C + + 5 }67 }
3.java encapsulation: External programs are not allowed to be accessed directly and accessed in a certain way
Encapsulation method to hide the attribute shadow.
4. Package Pakage:
modifiers accessed in 2.Java:
3.this Keyword: Represents the current object, this. property; this. method
This is used in references to external classes outclass.this.name----to refer to variables in external classes
4.---------------------Inheritance---------------------
Subclasses can use the parent class and can override an unsatisfactory method, but the subclass is consistent with the parent class format, and the algorithm can be modified as described below
At the same time, during the operation of the sub-class, the program executes the construction method of the parent class, and then executes the constructor of the subclass.
Object initialization: If the object values in the parent class are first exported, the same property of the method in the object overrides the object property initialization value
5.final Keywords:
6.super keyword: Super uses the methods and properties of the parent class directly
5 polymorphic ************************************
Inheritance is the basis of polymorphism; //We can only point to subclasses by reference to the parent class, and cannot point to the parent class with the object of the child class
If the subclass has a method that the parent class does not have, the polymorphic error will occur if the unique method in the subclass is called Animal obj2=new Dog ();//The parent class refers to a method of a subclass
Obj2.watchdog ();//watchdog method is not in the parent class, if this is called, it will be an error.
6. Reference type conversions: No risk for up-type conversions, down-type conversions are risky (data overflow occurs)
Type Judging by keyword instanceof
7*********** abstract class: Retouching with the abstract keyword
java-Basic articles (classes and objects)