Object-oriented three features: encapsulation, inheritance, polymorphism
Packaging:
Syntax: Property privatization (private), providing a way to provide relative get/set to access (public),
The judgment of the business logic corresponding to the data of the attribute in the method of Set/get
idea: Packages outside of the program do not directly access the properties of this class, need among the methods provided by this class
access to the properties of this class, thereby increasing the code'ssecurity.
other points of knowledge related to:
construction Method: Used to describe the object creation process, you canconstructs a method to quickly create an object.
This keyword: represents this class of objects, calls the properties of this class ,methods, construction methods.
method Overloading: Method name is the same, parameter list is not the same
Inheritance:
Syntax: Subclass extends Parent class
thought: A common feature or behavior described by multiple classes can
The common parts of the class are extracted to create their parent class.
Benefits of Inheritance: Subclasses share the code of the parent class, which improves the reusability of the Code;
later extension and maintenance, just add the corresponding subclass.
other points of knowledge related to:
Super Keyword: An object that represents the parent class, invokes the properties of the parent class ,methods, construction methods.
abstract Keyword: abstraction, adornment class, adornment method.
static keyword: statically, decorated property, method, code block,Inner class
Final keyword: Finally, cosmetic properties, methods, classes
method Overrides: Method name is the same, parameter list is same, return value typeSame,
modifier greater than or equal to the access modifier of the parent class
Polymorphic :
Syntax: Parent class object name =new subclass ();
thought: A reference to a parent type can point to the memory space of a child class object in memory,
it is convenient to design the parameters and return value types of the method, you can
designed to be a parent object, such a method is relatively concise when implemented, and in late
The method is easier to extend.
in code, polymorphic use is more of a parent class reference to a subclass object,
automatically type conversions (up), but sometimes you need to call subclasses
in their own things, this time you need to also atomic class, called coercion type conversion
(downward transition), use the instanceof operator to do the type of
judgment.
The idea of Java object-oriented programming