News for hackers. Stuff that matters.
Re:Incorrect Core Java Interview Answers by Confusion on Friday July 22, 2011 @10:50AM (#2793740)
Everything in Java is passed by value, as is the case in, for example, C[1] and Ruby. That the value that is passed is also called a reference does not change the fact that it is not call-by-reference.

There is a simple way to check whether a language does call-by-reference: can you write a swap function such that after calling swap(a, b), the variables a and b in the calling function refer to different values than before? In Java this is impossible.

Because the terminology is so confusing when object reference values are being passed-by-value, Barbara Liskov suggested we call it call-by-sharing.

[1] you can make C look like it's doing pass-by-reference by throwing some & and * operators around. That doesn't change the fact that it is purely call-by-value.

Re:Incorrect Core Java Interview Answers by JoeAltmaier on Sunday July 31, 2011 @08:55AM (#2828224)
I believe any object passed in Java can be modifed by the receiving method, right? So that is pass-by-reference. If we want to say we're really passing a reference by value, that begins to be silly - if the object passed can be modified, its a reference.