This week's giveaway is in the Android forum.
We're giving away four copies of Android Security Essentials Live Lessons and have Godfrey Nolan on-line!
See this thread for details.
The moose likes Beginning Java and the fly likes Why pass By reference is not working with String Object Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Android Security Essentials Live Lessons this week in the Android forum!
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "Why pass By reference is not working with String Object" Watch "Why pass By reference is not working with String Object" New topic
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: 19655
    
  18

There is no such thing as pass by reference in Java: http://faq.javaranch.com/java/CallByReferenceVsCallByValue


SCJP 1.4 - SCJP 6 - SCWCD 5 - OCEEJBD 6
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
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Why pass By reference is not working with String Object
 
Similar Threads
after nullfiying the object in method, how does the object still able to access its instance variabl
Pass By Reference
classis problem -- pass reference in method
PBValue or PBRef Comprehensive Detail
Query in Strings -Pass by Reference