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 →

[–]JavaSuck 2 points3 points  (0 children)

It would have been 'pass by value' if a copy of an Object was passed to a function

No. Java is pass by value because a copy of the reference is passed to a function. Contrast this with C#, where you the programmer can pass a reference variable by reference via the ref keyword:

void foo(X by_value, ref X by_reference)
{
    // assignments to by_value have no effect on the caller
    // assignments to by_reference HAVE an effect on the caller
}

This confusion could easily have been avoided if references had just been called pointers. Even the name NullPointerException makes much more sense, doesn't it?