| Author |
Why pass By reference is not working with String Object
|
Ravi Kiran Va
Ranch Hand
Joined: Apr 18, 2009
Posts: 2234
|
|
Hi
Can you please tell me
Why this pass By reference is not working .
I am sending an String Object into a Method as Parameter and changing its value inside the method .But its not changing its value .
Please help.
But to my surprise the Output is Ravi Only .
Thank you .
|
Save India From Corruption - Anna Hazare.
|
 |
Patricia Samuel
Ranch Hand
Joined: Sep 12, 2007
Posts: 300
|
|
|
Because the very first Rule about the String is - It is immutable.
|
 |
Ravi Kiran Va
Ranch Hand
Joined: Apr 18, 2009
Posts: 2234
|
|
oh i forgot .
Thank you very much.
|
 |
Rob Spoor
Sheriff
Joined: Oct 27, 2005
Posts: 19216
|
|
|
There is no such thing as pass by reference in Java: http://faq.javaranch.com/java/CallByReferenceVsCallByValue
|
SCJP 1.4 - SCJP 6 - SCWCD 5
How To Ask Questions How To Answer Questions
|
 |
sanjit nayak
Greenhorn
Joined: Oct 20, 2009
Posts: 2
|
|
|
There is no such thing as pass by reference in Java: In java it supports call by value
|
 |
 |
|
|
subject: Why pass By reference is not working with String Object
|
|
|