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