Java Handle Interpretation

Source: Internet
Author: User

" manipulating objects with handles"

Each programming language has its own method of data processing. Sometimes programmers have to keep an eye out for what type of work is being prepared. Have you used some special syntax to manipulate objects directly, or have you dealt with objects that are indirectly represented (C or C + + pointers)? All of this has been simplified in Java, and anything can be seen as an object. Note that although everything is "treated as" an object, the manipulated identifier is actually a "handle" (Handle) that points to an object. You can also see that some people call it a "reference" or even a "pointer". This scenario can be imagined as using a remote control Panel (handle) to manipulate the TV (object). Just hold the remote control Board, it is equivalent to master the channel connected to the TV. But once we need to "change the channel" or "Turn down the small sound", we actually manipulate the remote control Board (handle), and then the remote control Board to manipulate the TV (object). If you want to walk around the room and want to keep control of the TV, you have a remote control board, not a TV. In addition, the remote control board can exist independently even without a TV. In other words, simply owning a handle does not mean that an object must be connected to it. So if you want to accommodate a word or sentence, you can create a string handle: string S; But the only thing created here is the handle, not the object. If you send a message to s at this point, you get an error (run-time). This is because S is not actually connected to anything (i.e. "no TV"). Therefore, it is safer to create a handle and remember to initialize it anyway: string s = "asdf"; however, here is a special type: strings can be initialized with quoted text. Typically, you must use a more general type of initialization for an object.

Java Handle Interpretation

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.