Re: Is java using call by reference?# Java - 爪哇娇娃
a*o
1 楼
generally, if a func is call by value, you have no way to
change the value.
if it's call by reference, you can change it if it give you
such method.
In java, every object is a reference, and func is call by
value. So if you call f(o), you can not make o refer to
other objects, which means it is call by value. But you can
use o.setXXX to change o's state.
Just like in C
f(A* p);
it is call by value (value of the pointer), but you can call
p->setXXX() to change the state.
change the value.
if it's call by reference, you can change it if it give you
such method.
In java, every object is a reference, and func is call by
value. So if you call f(o), you can not make o refer to
other objects, which means it is call by value. But you can
use o.setXXX to change o's state.
Just like in C
f(A* p);
it is call by value (value of the pointer), but you can call
p->setXXX() to change the state.