Thinking in Java 4 Learning (a) everything is an object

Source: Internet
Author: User

One: where objects are stored

1. Register: Inside the processor, the fastest storage area, by the compiler according to the needs of the allocation, we have no control in the program.

2. Stack: In general RAM (random access processor), the basic type of variable data and object reference, but the object itself is not stored in the stack

3. Heap: Store all new objects.

4. Constant storage:

5. Non-RAM storage: Permanent storage space such as hard disk

Two: scope

The scope is determined by the position of the curly braces.

{

string s = new String ("a string");

}//End of Scope

The reference s disappears at the end of the scope, and the string object that s points to continues to occupy the memory space

Three: Class

If a member of a class is a basic data type, Java ensures that it obtains a default value even if it is not initialized. However, the method of ensuring initialization does not apply to " local " variables (that is, fields that are not a class)

If you remove the comment, you will get an error, that is, compile.

Thinking in Java 4 Learning (a) everything is an object

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.