jump to navigation

Pass by value vs. Pass by reference June 23, 2005

Posted by javafoo in java interview, javanotes, OOAD.
trackback

Always pass by value, if you ever say pass by reference, you will be rejected for sure. (in the interview that is)
You don’t believe me, this guy explains it far more better than I ever can.

Comments»

1. Frankie Fuentes - July 14, 2007

Ok. There’s no question about java’s only semantics on functions is pass by value. But what about if you want to implement swap function with parameters (obj1, obj2) so how are you going to do it? Some says you should do it inline, I say it would be buggy if there’s so many swapping happening on the code. So I think java designers have at least provided a pass by reference even if it is just a convenience preprocessing such as inline functions on C++. Imagine a code with full of swapping lines with out a helper function to do it.


Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: