|
|
|
|
|
by lmm
2976 days ago
|
|
If you write foo(&a), both "you pass a by reference" and "you pass &a by value" are fair descriptions of what happens. The confusion arises because Java doesn't explicitly distinguish between a and &a; if you write "Foo a = new Foo();" in Java, the behaviour is similar to "Foo *a = new Foo();" in C++. So if we ask how "a" is passed, is the "a" we're talking about the reference or the value? |
|
Seems weird to me to say that Java "passes by value" when all objects being passed are actually references to objects.