Java Programming Ideas: Introduction to 1 objects

Source: Internet
Author: User

There are two kinds of common high-level languages: object-oriented and process-oriented, the typical C, it is a structured language, simply speaking, is to solve a problem, is divided into a number of successive relations of the steps, coherent up can be resolved. For example, put the elephant into the refrigerator program, the process-oriented, the first step: Open the refrigerator; Step two: Put the elephant in the refrigerator; step three: Close the refrigerator door. This is the process-oriented language, just a main function entry, from top to bottom execution, step by step.

But this is not the idea of the typical object-oriented language of Java, which now illustrates object-oriented thinking from the Java 5 features of thingking in Java.

One: All things are objects. Or an example of the elephant above. For object-oriented solutions, thinking about this problem is not a logical sequence of considerations, but the first to determine what objects: elephants, refrigerators.

Two: A program is a collection of objects that they tell each other to do by sending messages. The above example: The purpose is to put the elephant into the refrigerator, objects have, elephants and refrigerators, elephants to put in the refrigerator, need to put the refrigerator before the notice, open the door, the elephant in, notify the refrigerator, close the door.

Three: Each object has its own storage that is composed of other objects. This is not discussed first.

Four: Each object has its type. An object is an instance of a class, such as: An elephant is a class, but not a specific thing, the elephant to put in the refrigerator (named Xiaoming) is an example, the refrigerator is the same.

Five: All objects of a particular type can receive the same message. This is very important and useful. For example, elephants and dogs belong to animals, so they will have the same parts, for example, to sleep, therefore, if the animal class is well thought out, it will reduce the complexity of the implementation of elephants, dogs, lions, and those belonging to specific classes of animals.

Java Programming Ideas: Introduction to 1 objects

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.