Home  >  Article  >  Java  >  What is object-oriented in java

What is object-oriented in java

(*-*)浩
(*-*)浩Original
2019-05-27 17:37:2515005browse

Object-oriented

What is object-oriented in java

Object-oriented is relative to process-oriented

Object-oriented and process-oriented are both An idea

Process-oriented emphasizes functions and behaviors

Object-oriented: encapsulate functions into objects and emphasize objects with functions

Object-oriented is based on process-oriented The

process-oriented example:

Putting the elephant into the refrigerator is divided into the following steps: open the refrigerator door; put the elephant in; close the refrigerator door ( Emphasis on the process and the behaviors involved in the process (emphasis on behavior, action, process)).

Consider using object-oriented thinking: Whether it is opening the refrigerator, putting in the elephant, or closing the refrigerator, all operations are operating on the refrigerator object, so all functions only need to be defined on the refrigerator object. There are all the functions of opening, storing and closing.

As can be seen from the above, object-oriented is an idea that can simplify complex problems. Programmers do not need to understand the specific implementation process, but only need to direct the object to implement the function. For example, the interviewer interviews the interviewer, which is the embodiment of object-oriented. The interviewer needs to find an object (interviewer) with programming capabilities, and I am an object with programming capabilities. After the interview, let the interviewer program, and the interviewer will to implement programming functions.

Three basic characteristics of object-oriented: encapsulation, inheritance, and polymorphism. The object-oriented process is the process of finding objects, establishing objects, using objects, and maintaining relationships between objects.

1. Encapsulation
Hides the properties and implementation details of the object, and only provides public access to the outside world, isolating changes, making it easier to use, and improving reusability and security.
2. Inheritance
Improve code reusability; inheritance is the prerequisite for polymorphism.
3. Polymorphism
Reference variables defined by the parent class or interface can point to instance objects of the subclass or specific implementation class. Improved program scalability.

Category: It is a description of things in real life.

Object: It is this kind of thing, an individual that actually exists.

Such as the objects in real life: Zhang San and Li Si. If you want to describe the objects Zhang San and Li Si, you need to extract the common content in the objects. That is, the extraction of common features of specific objects. When describing, the common features of these objects are: name, gender, age, learning java function. And each student has his own unique name, gender, age, and learning style.

In Java, the description is implemented in the form of a class, and the class is implemented through the entity generated by the new operator, and this entity is mapped to Java in the heap memory. To put it simply, the description is the class defined by class, and the specific object is the entity created by Java using new in the heap memory.

Describing things is actually describing the attributes and behaviors (methods) of things. The attributes correspond to The variables and behaviors in the class correspond to the functions (methods) in the class. In fact, defining a class is describing things and defining attributes and behaviors. Attributes and behaviors together become members of the class (member variables and member methods).

The above is the detailed content of What is object-oriented in java. For more information, please follow other related articles on the PHP Chinese website!

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn