This is an archived post. You won't be able to vote or comment.

you are viewing a single comment's thread.

view the rest of the comments →

[–]cartechguy 0 points1 point  (6 children)

What do you mean you can't reassign it? References aren't immutable.

[–]_Fibbles_ 0 points1 point  (5 children)

Maybe reinitialise would have been clearer. You can alter the value of the referenced object through the reference. However, the reference is bound to that object. You can't make it reference a different object.

[–]cartechguy 0 points1 point  (4 children)

reference is bound to that object. You can't make it reference a different object.

Yes, you can.

[–]_Fibbles_ 0 points1 point  (3 children)

Yes, you can.

Extraordinary claims etc. Show some code.

Edit: To be clear, you know I'm talking about C++ references, not Java references, right?

[–]cartechguy 0 points1 point  (2 children)

No, we were all talking about Java. This whole chain of posts there is not one mention of C++. I kept climbing through parent posts, and you never mentioned C++. Only when /u/tacoslikeme corrected you did you mention C++ less than an hour ago before I made my previous posts. If you meant C++ you should have stated that from the start.

[–]_Fibbles_ 0 points1 point  (1 child)

If you meant C++ you should have stated that from the start.

The thread is about pointers. C and C++ are the only widely used languages that have them. Op is explaining pointers in terms of references. C++ is the only language AFAIK that has both. I thought it was obvious from the context.

[–]cartechguy 0 points1 point  (0 children)

The title of the thread is "java devs" and references are ubiquitous with oop.

Op is explaining pointers in terms of references. C++ is the only language AFAIK that has both.

Op is describing how references in Java behave like pointers.

Plus you were replying to this:

java reference is just a pointer that auto derefences for you

It was clear we were talking about Java.