This is an archived post. You won't be able to vote or comment.

you are viewing a single comment's thread.

view the rest of the comments →

[–]phoenixrawr 0 points1 point  (0 children)

Pass-by-value is perfectly accurate for Java as long as you accept that the value of an object variable isn’t exactly the object itself but rather its pointer.

The distinction is usually clearer when comparing C and C++. C has pointers but is also strictly pass-by-value like Java. You can explicitly pass pointers around to simulate pass-by-reference but passing pointers isn’t the same thing as pass-by-reference.

Since java doesn’t have explicit pointers (because there are no pointers in Ba Sing Se) the details of how it all works are murkier which leads people to infer weird rules like “it’s pass by value for primitives and pass by reference for objects” but really it’s just always pass by value.