Win a copy of OCP Java SE 8 Programmer II Exam Study Guide this week in the OCP forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

pass reference to reference/address of?  RSS feed

 
Ranch Hand
Posts: 47
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Coming from C/C++, I just want to check that I did not miss something WRT to parameters. Since there is no "pointer to a pointer", etc, it seems it is impossible to do something like this:



Such that A will now be "whatever".

I recognize this is not an insurmountable obstacle and can be remedied by using a simple class instead of a static function, but before I get into that habit I wanted, like I said, to make sure I didn't miss anything.

Thanks!
 
Sheriff
Posts: 23451
46
Eclipse IDE Firefox Browser MySQL Database
  • Likes 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Yes, that's right. For a short explanation have a look at our FAQ entry about that: Call By Reference Vs Call By Value. And for a longer explanation follow the link from that page to the "campfire story" about it.
 
Bartender
Posts: 6109
6
Android IntelliJ IDE Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

Paul Clapham wrote:Yes, that's right. For a short explanation have a look at our FAQ entry about that: Call By Reference Vs Call By Value. And for a longer explanation follow the link from that page to the "campfile story" about it.



I just saw last night that Kurniawan's "Java 7" book makes the erroneous claim that "reference variables are passed by reference." It's shocking how many resources get that wrong. (That book has some other glaring errors too, though, so I guess I shouldn't be surprised it makes this mistake.)
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!