object creation and initialization procedures in Java

Source: Internet
Author: User

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 of which are basic data types), reference types, and null types. Where reference types include class types (with arrays), interface types.

The following statements declare some variables:

The following is a reference fragment:
int k;
A; A is the name of the object variable for the a data type.
b b1,b2,..., b10000;//assumes that B is an abstract class or interface.
String s;

Note: From the data type and variable point of view, the basic data type variable K, class type variables A and S, abstract class or interface type variable B (10,000), which are variables (identifiers).

2. About handles (handle)

To distinguish between variable identifiers of reference types and base data type variable identifiers, we specifically use handle to address variable identifiers of reference types. In the example above B1 to b10000, a, s are handle. Handle intuitive look is the handle, handle, we use the computer industry commonly used in Chinese translation "handle."

2.1 Meaning of "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 as application instances, Windows, controls, bitmaps, GDI objects, and so on. The Windows handle is somewhat like a file handle in the C language.

From the definition above we can see that the handle is an identifier, is to identify the object or project, it is like our name, everyone will have a, different people's name is not the same, but there may be a name and you the same person. It's just a 16-bit unsigned integer from the data type. Applications almost always get a handle by calling a Windows function, and then other Windows functions can use the handle to refer to the corresponding object.

If you want to know the handle more thoroughly, I can tell you that the handle is a pointer to the pointer. We know that the so-called pointer is a memory address. After the application is started, the objects that make up the program reside in memory. If we simply understand, it seems that we just know the first address of this memory, then we can access the object at any time with this address. But if you really think so, then you're wrong. We know that Windows is a virtual memory-based operating system. In this system environment, the 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 always changes so, where should we go to find the object?

To solve this problem, the Windows operating system frees up some internal storage addresses for each application to specifically register the address changes in memory for each application object, and the address (the location of the storage unit) itself is unchanged. When the Windows Memory Manager moves the object's location in memory, it stores the address of the new object to the handle. So we just have to 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) → address of object in memory ────→ object in memory (unstable) → actual object

Meaning of the handle in 2.2Java

Having a deep understanding of the meaning of the previous "Windows programming" in the handle, we can say that handle is a term we really need to learn java. Its meaning is to differentiate between the "object itself" and the object variable (or, strictly, the variable identifier of the data type to which the object belongs).

2.3 Return to the variable declaration in 1:

You should now glance at the comments below.

int k, J;//k contains an integer number.

A; A inside the store address.

B b1,b2,..., b10000;//b1,...,b10000 inside the store address.

String s; s inside the store address.

object creation and initialization procedures in Java

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.