File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
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 Spring in Action this week in the Spring 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: 19718
    
  20

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