Analyze the related conceptual issues involved in the process of object creation and initialization in Java, the concepts of Java stack and heap (heap), objects, references, and handles.
Data types in 1.Java
There are 3 data types in Java:
Basic data types (in Java, Boolean, Byte, short, int, long, char, float, double, eight are basic data types)
Reference type
Null type
Where reference types include class types (including arrays), interface types.
The following statement declares some variables:
The following is a reference fragment:
int k;
A A; A is the name of the object variable for a data type.
b b1,b2,..., b10000;//assumes B is an abstract class or interface.
String s;
Note: From the point of view of data type and variable, basic data type variable K, class type variable A and S, abstract class or interface type variable B (10,000), they are all variables (identifiers).
2. About handle (handle)
To differentiate between variable identifiers of reference types and basic data type variable identifiers, we specifically use handle to address the variable identifier of a reference type. B1 to b10000, a, and s are all handle in the example above. Handle intuitive look is the handle, handle, we use the computer industry commonly used in Chinese translation "handle".
2.1 Meaning of the handle in "Windows Programming"
A handle is a unique integer used by wondows to identify objects that are created or used by the application, and Windows uses a variety of handles to identify such things as application instances, Windows, controls, bitmaps, GDI objects, and so on. A Windows handle is somewhat like a file handle in the C language.
As we can see from the above definition, the handle is an identifier, it is to identify the object or project, it is like our name, everyone will have a different person's name is not the same, but, there may be a name and you the same person. From the data type it is just a 16-bit unsigned integer. An application almost always obtains a handle by calling a Windows function, which can then be used by other Windows functions to refer to the object.
If you want to get a better understanding of the handle, I can tell you that the handle is a pointer to a pointer. We know that a pointer is a memory address. After the application is started, the objects that make up this program reside in memory. If we simply understand it, it seems that we can use this address to access the object at any time as long as we know the first address of this memory. However, if you really think so, then you are wrong. As we know, Windows is an operating system based on virtual memory. In this system environment, Windows memory manager often moves objects back and forth in memory to meet the memory needs of various applications. The object being moved means that its address has changed. If the address changes so much, where do we go to find the object?
To address this problem, the Windows operating system frees up some of the internal storage addresses for each application to specifically register address changes in memory for each application object, and this address (the location of the storage unit) itself is unchanged. After the Windows Memory Manager moves the object in memory, the new address of the object is communicated to this handle address to save. So we just remember this handle address to know indirectly where the object is in memory. This address is assigned by the system when the object is loaded (load) and released to the system when the system is unloaded (Unload).
Handle address (Stable) → Record the address of the object in memory ────→ the object in memory (unstable) → actual object