Java References vs C++ Pointers and References

Semantically Java references are similar to C/C++ pointers.

Syntactically Java references are similar to C++ references.

  Java references C/C++ pointers C++ references
Points at objects Yes Yes Yes
Initialized with new Yes Yes No
Can be null Yes Yes No
Can be updated to point at a different object Yes Yes No
Pass by value Yes Yes No
Is called “reference” Yes No Yes
Is implicitly dereferenced Yes No Yes

Comments