Does Java have pointers?

As pointed out, Java has references. How are these different ?

  1. you can’t perform arithmetic or other such operations on these
  2. they do not point to the memory containing the object (i.e. they are not pointers by another name). The JVM is at liberty to move objects around within the VM memory, and most likely will do during garbage collection. The references however still point to that object, despite its movement within memory.

So they’re not like C++ references (pointing directly to an object). Perhaps a better name would be handle.

Leave a Comment