Java the next day

Source: Internet
Author: User

The difference between a member variable and a local variable:

1. Member variables are defined in the class and can be accessed throughout the class. A local variable is defined in a function, statement, local code block, only valid in the area to which it belongs.

2. member variables exist in the object of the heap memory. Local variables exist in the method of stack memory.

3. The member variable exists as the object is created and disappears as the object disappears. Local variables exist with the execution of the owning region and are released as the end of the owning region.

4. member variables have default initialization values. Local variables do not have default initialization values.

Value types pass memory graphs that are passed with reference types:

Encapsulation (encapsulation): Refers to the properties and implementation details of hidden objects, providing public access only externally.

Benefit: Isolate the change. Easy to use. Improve reusability. Improve security.

Encapsulation principle: Hide content that does not need to be provided externally. Hides properties, providing public methods for accessing them.

Private: is a permission modifier that is used to decorate a member. Private content is only valid in this class.

Note: Private is only an embodiment of encapsulation.

The representation of a two-dimensional array in memory:

Java the next day

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.