Java FAQ 1000 Question

zhaozj2021-02-16  74

1. Java delivery is a copy of the reference, neither reference itself, not an object

When I saw Think in Java, I mentioned that Java is transmitted, but it has not attracted attention. Until a practical problem, I realized this most basic problem.

Everything in Java is a value transfer. You can change the attribute value in the referenced object, but it is not possible to change this object reference itself. That is, when an instance of an object is created, Like this: Apple A = New Apple (); A existing is the address of this object instance. This address, that is, the value of a as a parameter is transmitted to a function, A itself will not change.

转载请注明原文地址:https://www.9cbs.com/read-15861.html

New Post(0)