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.