1, facing the object (oop)
Object-oriented: Everything is an object, pay more attention to things, do your own things by yourself.
For example: What should I do if I want to put the elephant in the refrigerator? Many people would think of opening the refrigerator door first, then putting the elephant in, and closing the door finally. This put the elephant in. From the above description, we can conclude that opening the refrigerator door, then putting the elephant in, and finally closing the door. This is actually a process, and the final result is to put the elephant in the refrigerator. In this process, we can treat the refrigerator as an object and open the refrigerator door, put the elephant in, and then close the refrigerator door. We can all regard this series of actions as the method of the refrigerator object, and we have to take Put the elephant in the refrigerator. We only need to call these methods of the refrigerator. As for how the refrigerator implements these methods, you don’t need to know. All you need to know is the result: the elephant is placed in the refrigerator. This is object-oriented.
Advantages: Low code coupling, high code reusability, easy to extend and maintain. Low coupling, high cohesion.
The object-oriented language has high reusability and high development efficiency.
Disadvantages: Code operation efficiency is low.
Abstraction: Abstract a concrete thing into a class (file).
Properties (static): Variables defined in the class.
Behavior (dynamic): methods defined in the class.
Code understanding:
package com;
/*
* Class:
* Abstract a thing into a class (abstraction: in the process of abstraction, abstract whatever is used)
*-When defining a class, in the class Can only contain attributes and behaviors
* -Attributes (static): variables defined in the class
* -When attributes are defined, the system will initialize them by default
* -Value: 0
* -char :’