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

pass value or pass reference

 
Jingxian Zhou
Greenhorn
Posts: 28
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

Why is pass value,other is pass reference?
 
Christophe Verré
Sheriff
Posts: 14691
16
Eclipse IDE Ubuntu VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I don't see any method calls. Why are you asking about pass by value or pass by reference ?
 
Jingxian Zhou
Greenhorn
Posts: 28
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Christophe Verré wrote:I don't see any method calls. Why are you asking about pass by value or pass by reference ?

Thanks for your answer.

Sorry,my question is not correctly.I have a confused that the result is false and true.Why ?
 
Abimaran Kugathasan
Ranch Hand
Posts: 2066
Clojure IntelliJ IDE Linux
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Jingxian Zhou wrote:
Sorry,my question is not correctly.I have a confused that the result is false and true.Why ?


This is related to object mutability. Wrapper Class Object are immutable, and StringBuilder object are mutable!
 
Jingxian Zhou
Greenhorn
Posts: 28
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Abimaran Kugathasan wrote:
Jingxian Zhou wrote:
Sorry,my question is not correctly.I have a confused that the result is false and true.Why ?


This is related to object mutability. Wrapper Class Object are immutable, and StringBuilder object are mutable!


Thanks Abimaran Kugathasan.

Can you tell me the reference ?
 
Abimaran Kugathasan
Ranch Hand
Posts: 2066
Clojure IntelliJ IDE Linux
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Jingxian Zhou wrote:
Can you tell me the reference ?


Have Googling! You'll find a lot.
 
Shanky Sohar
Ranch Hand
Posts: 1051
Eclipse IDE Firefox Browser
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
This is related to object mutability. Wrapper Class Object are immutable, and StringBuilder object are mutable!


we know that string buffer object are mutable.......that means
sb1.append("5"); will add 5 to sb1........
and sb2 is pointing to sb1.......so it will return to............

but if the wrapper class objects are immutable that means..........."x==y" must be identical........but it is returing False......why.......
 
Abimaran Kugathasan
Ranch Hand
Posts: 2066
Clojure IntelliJ IDE Linux
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
phil sohan wrote:
but if the wrapper class objects are immutable that means..........."x==y" must be identical........but it is returing False......why.......


What happen when you do this operation?


There will be a new Integer object will be created with the value(the incremented value) and x will be assigned to the newly created object.

Try the below coding.


You'll get it!
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic