Object-oriented foundation of jav

                       什么是面向对象?

  Object-oriented is a programming idea that conforms to the habits of human programming thinking. The use of objects in a program to map real things, and the relationship between objects to describe the relationship between things, this idea is object-oriented.

                      面向过程和面向对象区别

Process-oriented: The emphasis is on the process, and each step of the operation must be done by yourself.
Object-oriented: The emphasis is on the object, and the operation is performed by the object for us.
Example:
  Eating a roast duck Orientation
process: buy a small duck-sell feed-raise a large duck-kill a duck-roast a duck-eat a duck-clean up the tableware.
Object-oriented: go to Quanjude to buy a duck-eat it.

                    面向对象的好处和三大特征

benefit:

  1. Simplify complex problems.
  2. More in line with people's programming ideas (lazy thinking).
  3. Turn programmers from executors to commanders.

Three characteristics :
Insert picture description here

                       java中类与对象

What is a class?
  Class is a vague concept, referring to a collection of things and behaviors that share common attributes.
For example: animals, plants, cars.

What is an object?
  The object is a concrete manifestation of a certain kind.
For example: animals (pigs, cows, ducks, dogs ...)

Class format
Insert picture description here
<method in class is equivalent to function in c language>

                          访问修饰符

Insert picture description here
Insert picture description here
Insert picture description here
Insert picture description here
Insert picture description here

                         类的封装

What is encapsulation?
  Encapsulation is to hide the details in the object without being directly accessed by the outside world.
The benefits of packaging?
  Can improve the safety of the program.
How to package?
  First, use peivate to rest on member variables, and then establish two public access and outgoing methods to operate on and out of member variables.

                          方法

Definition of method :
  Two clear:
   1. Clear parameter list.
   2. Explicit return value type.

Method overloading : The
method name is the same, but the parameter list is different (the number of data is different or the data type is different), regardless of the type of the return value. The parameter list determines which method is called.

Method recursion :
Method recursion is the process of method calling itself. It should be noted that the number of recursion should not be too much, and there must be an end condition.

Published 16 original articles · praised 3 · visits 422

Guess you like

Origin blog.csdn.net/qq_23321269/article/details/105363103