Reference one side of the unknown

Source: Internet
Author: User
Tags garbage collection

Reference one side of the unknown
Java does not support pointer, only provide Reference, beginners are often puzzled, especially the information structure of the students, their minds the first thought is: "No pointer, how this, it can not be done linked list and tree data structure?" "Everyone knows that Reference is an intelligent point er, it has pointer benefits, and not like pointer to programmers themselves Reference (*) and dereference (&), not like pointer The same will trespass into the memory restricted area caused crash. Because the benefit is many, therefore Reference already is the modernized procedure language important essential function.

What the! You say that the senior language of XX does not support Reference, then you can bury it in the historical ashes of 20th century.

Java handles data by using pass by value as long as the basic form (including Boolean, Byte, short, int, long, float, double, char) is used, and all other forms are by refer en Ce. But I find that this is likely to change in the future because Java language byvalue as reserved word (not keyword). When Java turns byvalue into keyword, the value of the non basic type can pass by value, but I believe that Java must also start supporting copy constructor as a complementary measure, after all, using deep copy or sh Allow copy (even deep and shallow) still have to let programmer decide.

mentioned above: As long as the basic types (including Boolean, Byte, short, int, long, float, double, char) all use pass by value, all other forms are by Reference.

What exactly is pass by value? What is pass by Reference? For example, pass by value is the information of the "Fen" passed through the past, passes by Reference is the information of the "book" passed through. (Note: Ever since that news, with the term "Buddha" and "fen", I have found that I have to explain to the students Refere
The idea of nce is much easier, too. Because objects are always pass by Reference, an object is often pointed at the same time by multiple variable.


Java provides a mechanism for automatic memory management, known as garbage collection (garbage collection). When an object is no longer indicated by any variable, it means that the object will never be exploited again, and a thread in the Java virtual machine responsible for collecting garbage will come out at the right time to reclaim the block of memory.

<

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.