• Post Reply Bookmark Topic Watch Topic
  • New Topic

Passing value  RSS feed

 
Kamila Bertran
Ranch Hand
Posts: 47
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

I've got a method:


than a code:


why the result is 11, 11 and not 21, 21? 
 
fred rosenberger
lowercase baba
Bartender
Posts: 12542
48
Chrome Java Linux
  • Likes 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
because you are passing in the VALUE. 

Say I had the number 10 written down on a piece of paper, and then told you "My value is 10".  You write down 10 on your piece of paper.

You then erase your 10, and replace it with a 20. You then throw your piece of paper away.

I then say to myself "I need to change the value I have on my piece of paper and increase it by 1", wouldn't you expect me to end up with 11?
 
Kamila Bertran
Ranch Hand
Posts: 47
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I definitely would. Thanks.
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!