9 ms·
I thought this was common knowledge. I was taught that Java is pass-by-value in compiler-writer terms, but as a programmer you can think of it as pass-by-refere
by cup-of-tea 9y ago
I thought this was common knowledge. I was taught that Java is pass-by-value in compiler-writer terms, but as a programmer you can think of it as pass-by-reference because you have no control over it.
- Terr_ 9y agoI believe the difficulty with "pass by reference" is that the phrase implies (at least in other languages) that the function-body can potentially alter variables in the caller's scope, by assigning something to the parameters it is given. In other words, "C-style" pass-by-reference means this function would have an undesirable side-effect: void foo(Thing x){ x = null; }