Java是通过引用传递的吗?
问题描述:
Java是否真的支持通过引用传递?
Does Java really support passing by reference?
如果没有,为什么我们有==运算符来查找具有相同引用的两个对象?
If it doesn't, why do we have the == operator for finding two objects with the same reference?
答
Java使用传值,而非参考...
Java uses pass by value, not by reference...
但是,对于非原始类型,值是引用的值。
But, for non primitive types the value is the value of the reference.
所以==比较对象的引用值。
So == compares the values of references for Objects.