The object-oriented ideas, classes and objects of Java learning

Source: Internet
Author: User
Tags access properties

First, let's talk about process-oriented
    • Process-oriented "(Procedure oriented) is a process-centric programming idea. "Process-oriented" can also be called "record-oriented" programming ideas, they do not support rich "object-oriented" features (such as inheritance, polymorphism), and they do not allow the mixing of persistent state and domain logic. is to analyze the steps required to solve the problem, and then use the function to implement the step by step, the use of a one-time call in turn.
    • This idea applies and solves the simple problem, when the program is large to a certain extent, its debugging and maintenance is very difficult. This idea is closer to the computer, is not conducive to large-scale program design, code reuse support is not good enough.
Second, object-oriented
    • The idea of object-oriented programming is closer to the human mind, the program uses the interaction between object and object to complete the function of the program, and the object in the program is the abstraction of the object existing in the real life. The three important characteristics of object-oriented programming are encapsulation, inheritance and polymorphism.
    • The basic idea of object-oriented programming is to abstract things from the real world into objects, and give the abstract objects the corresponding state and behavior, and accomplish certain tasks by responding to the message.
    • Object-oriented programs, where the state of an object is called an object's "properties," an object's behavior or function is called an object's method, an object's method implements a function of the object.
    • The object-oriented programming method is to abstract the state and behavior of the object in the real world into the object in the programming language, and achieve the unification.
Third, abstract
    • There are many objects in reality, and it is impossible to define a set of properties and methods for each object, which requires us to classify objects in the real world and abstract a class of objects with generality into one.
    • Class: Is an abstract data type, a collection and abstraction of the same object, and a uniform description of several objects with common behavior and attributes.
    • Object: The mapping and embodiment of a real-world entity in computer logic.
    • Class-To-object relationships: Class-"Object: Instantiate the class to produce the object." Object-Class: Abstracts an object into a class.

Iv. definition of Class

Syntax for class declarations:

[Modifier] class Name {

[Private/protected/public] Members ' declarations and definitions;

}

Where private, public, and protected are called access modifiers.

V. Instantiation of objects

The instantiation format of the object:

< class name > < object name >=new < class name > ([Parameter 1, Parameter 2, ...] );

Or

< class name >< object name >;

< object name >=new< class name > ([Parameter 1, parameter 2,...] );

Vi. access to class members

General form of Access Properties:< object >.< Property name >

General form of Access method:< Object name >.< method name > ([< parameter 1>,< parameter 2>, ...])


The object-oriented ideas, classes and objects of Java learning

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.