Win a copy of Functional Reactive Programming this week in the Other Languages forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Why pass By reference is not working with String Object

 
Ravi Kiran Va
Ranch Hand
Posts: 2234
Eclipse IDE Firefox Browser Redhat
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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 .
 
Patricia Samuel
Ranch Hand
Posts: 300
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Because the very first Rule about the String is - It is immutable.
 
Ravi Kiran Va
Ranch Hand
Posts: 2234
Eclipse IDE Firefox Browser Redhat
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
oh i forgot .

Thank you very much.
 
Rob Spoor
Sheriff
Pie
Posts: 20669
65
Chrome Eclipse IDE Java Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
There is no such thing as pass by reference in Java: http://faq.javaranch.com/java/CallByReferenceVsCallByValue
 
sanjit nayak
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
There is no such thing as pass by reference in Java: In java it supports call by value
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic