what is the difference between pass by reference and call by reference?

在java中通过引用和引用引用有什么区别?


Java does not pass any variables by reference.

It is tempting to think of objects being passed by reference in Java -- but harmful. Variables of object type are references. When passed, they are passed by value.

In other languages, pass-by-reference and call-by-reference are the same thing.

Edit: More detail is provided in the existing stackoverflow question "Is Java pass by reference?" (Spoiler: No.)


Important concept - Java has no concept of "pass by reference". Everything in Java is passed by value. When you pass an object reference to a parameter in a method call, what you are really doing it is passing a value that points to the reference of your object.

The following URLs explain this in greater detail: http://www.javaworld.com/javaworld/javaqa/2000-05/03-qa-0526-pass.html and http://javadude.com/articles/passbyvalue.htm?repost

Apparently (as noted in comments to your question) the terms "pass by reference" and "call by reference" mean the same thing.


You asked but, "pass by reference" and "call by reference" are same thing.

If you are looking for difference between pass by reference and pass by value check answers to

Pass by reference or pass by value?

But remember, Java passes parameter by value.

http://javadude.com/articles/passbyvalue.htm

http://academic.regis.edu/dbahr/GeneralPages/IntroToProgramming/JavaPassByValue.htm

链接地址: http://www.djcxy.com/p/20662.html

上一篇: 在java中将对象传递给方法似乎是通过引用(而Java是通过val)

下一篇: 引用传递与引用引用有什么区别?