Hi! Could Someone please explain me the difference between "Pass By Value" & "Pass By Reference" In Java? I can't understand it clearly. Please give some easy example and little description? Any help would be appreciated.

Thanks.:-/

Recommended Answers

All 5 Replies

Read this thread: http://www.daniweb.com/software-development/java/threads/371984/1602357#post1602357
and for future reference, search the forum before posting, maybe your question could have already been answered. If you still don't understand it let us know.

P.S I linked to my reply in that thread, but I encourage you to read the entire thread

commented: My thoughts exactly. Well done. +1

Pass by value- passing the copy of the value.

Pass by reference- passing the address itself rather than passing the value.

Pass by value- Pass primitive datatype variable.

Pass by reference- pass class Object.

> Pass by reference- pass class Object.
Nope, try again. Object reference is still passed by value. Google it, there are plenty of explanations about.

Fine. I am also learner.. But my professor taught me in that way..
I will go through it. Thank you.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.