Java Learning Small notes-objects and classes

Source: Internet
Author: User

This is the time I began to learn Java has been unable to understand a point, previously confined to a freshman to learn C + + ideas, dead and alive do not understand the concept of objects and classes. Now on the research, although these years did not knock on the Java code, but read again, found that they can also imperceptibly gradually understand.

Object: Represents an entity that can be clearly identified in the real world.

    • The state of an object, also known as a feature (property) or attribute (attribute), refers to those data thresholds that have their current values.
    • The behavior of an object (behavior, also known as an action) is defined by the method. One way to invoke an object is to require an object to complete an action.
    • Construction method: is to construct the object. is a special method, there are three kinds of particularity:
      • The construction method must have the same name as the class in which it resides.
      • The construction method has no return type, even void.
      • The construction method is called when an object is created using the new operator. The function of the constructor method is to initialize the object.

To allocate space in memory for a newly created object, access it by referencing the variable.

    • A class is equivalent to a programmer-defined type. A class is a reference type (reference type) The following statement declares that the type of the variable mycircle is the Circle type.
      • Circle mycircle;
    • The variable mycircle can refer to a circle object. The following statement creates an object and assigns its reference to the variable mycircle.
      • Mycircle = new Circle ();
    • You can write a statement that includes declaring an object reference variable, creating an object, and assigning a reference to the object to the variable.
      • Circle mycircle = new Circle ();
    • For reference type variables, the value stored by the corresponding memory is a reference and the storage address of the object.

Java Learning Small notes-objects and classes

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.