Object-oriented:
Process oriented:
Programming, the essence of software development solution? is abstraction.
What does abstraction need to abstract? (data, business logic)
What is abstract as a guide (oriented)?
Object-oriented: Data abstraction-oriented
Process oriented: Guided by the abstraction of business logic
Class: 1, Static Properties--Properties
2, dynamic Behavior--method properties, methods collectively referred to as members of the class
--Method
1, modifier return value type method name (formal parameter list) {
Method body
}
public void Move () {
SYSTEM.OUT.PRINTLN (name + "Moving");
}
Public access permission modifier (exposed)
Private (privately)
void return value type (NULL type)
Int,double,string ...
Move Method Name
Naming habits:
1, class name, first letter of each word, other letters lowercase
2, properties. Method Name The first word is all lowercase, the first letter of each word is capitalized, and the other letter is lowercase. Example: SetName ()
3, package name all lowercase
4, constant All letters capitalized example: Final int max_size; Final constant modifier
Method call Matching:
1, argument type and formal parameter type to match
2, return value and return value type to match in method
Procedure to invoke a method:
1, allocating temporary space for the called method
2, passing arguments to formal parameters
3, the process jumps to the called Method execution
4, after executing or encountering return, the process returns to the keynote method, while the method temporary space is released.
Note: A Java file can define multiple classes, but only one class declared by PUBILC, and this class with public declaration must match the file name
Pass by value (for all basic data types)
To pass (an object) by reference
Construction Method:
1, the construction method must have the same name as the class
2, the construction method does not return a value, and does not declare void
Three main features of object-oriented: encapsulation, inheritance, polymorphism
Inherited:
Abstract parent-child class relationship follows the principle that any local subclass applicable to the parent class must be applicable.
Note: Inheritance is not the best way to reuse code.
Keyword extends (extended)
Example: public class Bird extends animal{}
The process of generating an object:
1, allocating object space
2, assigning an initial value to a property
3, calling construct method
Theorem:
1, any main class object construction method will call the parent class constructor method
2, any class has a construction method, if the programmer does not define themselves, then the system will add a default construction method, if the system is defined will not add.
3, the construction method of any subclass the first line must be super (...). ), or this (... ), if the programmer does not write this, the system will default plus super (...). );
This (..... ); Call the other constructor methods of this class, he can only appear in the first row of the constructor method.
Super (..... ); Invokes the constructor of the parent class, which can only appear in the first row of the constructed method.
Super (); Calls a constructor that has no arguments in the parent class.
Calling the same name method in the parent class in the subclass with Super.xxx
This.xxx calling a member variable of the same name in this class
Method overrides:
1, released between the father and son classes;
2, same name, same parameter, same return value;
3, the access rights of subclass methods cannot be more closed than those of the parent method;
4, subclass methods cannot throw exceptions that are more broad than the parent class method
Object-oriented interpretation, naming conventions, method invocations, overwriting