Each programming language has its own way of handling data. Sometimes programmers have to keep an eye out for what type they are prepared to deal with. Have you used some special syntax to manipulate objects directly, or have handled objects that are indirectly represented? (c or pointers in C + +).
All of this is simplified in Java, and everything can be considered an object. Therefore, we can adopt a unified grammar, anywhere can be copied without error. Note, though, that everything is "treated" as an object, but the manipulated identifier is actually a "handle" to an object (Handle). In other Java reference books, 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 a television set (object). Just hold on to the remote Control Board, which is equivalent to mastering the channel connected with the TV. But once you need to "change channel" or "Turn off the small voice", we actually manipulate the remote control Board (handle), and then by the remote Control Panel to manipulate the television (object). If you want to walk around in your room and want to keep control of the TV, you have a remote control board instead of a TV.
In addition, even without a television, the remote Control board can be independent. That is, simply owning a handle does not mean that an object must be connected to it. So if you want to hold a word or sentence, you can create a string handle:
String s;
But the only thing created here is a handle, not an object. If you send a message to s at this point, you will get an error (run time). This is because S is not actually connected to anything (i.e. "no TV"). Therefore, a more secure approach is to: when you create a handle, remember to initialize it anyway:
String s = "asdf";
However, a special type is used here: strings can be initialized with quoted text. In general, you must use a more general initialization type for the object.
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.