6. Javase-Object-oriented introduction

Source: Internet
Author: User

Object-oriented :

Object-oriented itself is an idea, not a programming algorithm.

For example:

Object-oriented : refrigerator open, refrigerator storage, refrigerator off

Facing process: Open the refrigerator, put the elephant in, close the refrigerator door


process-oriented thinking: emphasis is on processes (actions and functions)

Object-oriented thinking: The emphasis is on objects (entities)

Process oriented:C language

Object-oriented:java,C + +,C #, Python

Object-oriented:

1. Conform to people's thinking habits

2. Simplifying Complex issues

3. To turn the performer who has been in the process of orientation into an object-oriented leader

Relationships between classes and objects:

1. A class is a model object that is the entity of the model (for example, the manufacturing process of a car)

2. Describe things in real life in the Java language (in the form of classes)

3. The description of a thing usually focuses on two aspects, namely, properties and behavior (four wheels, can run)

4. Simply define the property and behavior of the thing and defined in the class

Object:

1. This is actually the kind of entity that exists, created through new

2. Before writing the program must first analyze, for example, write the car class

1) to first analyze what the car's properties (color, number of tires), what behavior (running)

2) and then in the concrete instantiation of the


Memory: Heap memory (storage object), stack memory (storage temp variable)

Memory representation of the object: in Heap memory

The appearance of objects: for encapsulating data, and for array-like

Local variables and member variables:

1. Member variables are defined in the class and can be accessed throughout the class

2. Local variables are defined in the method, in the statement, in the local code block, in the area of the owning

3. Member variables exist in the object of heap memory

4. Local variables exist in the method of stack memory

5. Member variables are created as objects are created, disappearing as objects die

6. Local variables are changed as they belong to the region

7. member variables have default initialization values, local variables have no initialization values

8. Local variables and member variables have the same name: local variables will mask member variables


Note: The program must pay attention to the code is clear and concise, code reuse

Parameter passing between functions can be divided into reference parameter passing (heap) and basic parameter passing (stack); Note that when an object does a parameter, it is also a reference parameter passing type


Packaging:

1. In object-oriented, it refers to the properties and implementation details of hidden objects, and only provides public access interfaces externally

2. Improve security and provide access to external providers because the properties are controllable


Example: Computer host

such as the get and set methods of attributes, in the development process, the general member variables are private, and must be accompanied by a get and set method

This article is from the "Keyman" blog, make sure to keep this source http://keyman.blog.51cto.com/9807984/1676584

6. Javase-Object-oriented introduction

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.