Hacker News new | ask | show | jobs
by ohf 2976 days ago
> Java calls references, works more like C/C++ pointer, rather than C++ reference

What makes you say this? You can't do pointer arithmetic on Java references, and the internal memory model is completely obscured. C++ and Java references look similar to and are accessed like variables. The major difference is that Java references can be reassigned, like a pointer, which is necessary in a language without true pointers.

1 comments

In C++, references aren't objects (eg. they have no size and no address), they can't be stored in a vector, there's no way to operate on the reference itself, everything is transparently forwarded to its referent, there is always a referent.

In Java, a reference is a value, it can be stored in an ArrayList like a normal value, you can operate on the reference itself (reseating it, comparing two of them, comparing to null), there is not always a referent.

Touche.