Are Java pointer integers?

I take data structures and analysis. We examined how assignment and comparison of object types is much slower than assignment and comparison for basic types such as int.

I remember learning C (all these thirty years ago) and as pointers to C (or were) whole calls. Whether Java is similar today is a reference to an instantiated object inside an integer memory address, and as such comparisons such as

if (MyObject != null) {...} 

integer operation within?

Hope my question is clear. I am doing research, and I cannot find a clear answer about how Java manages its dynamic memory.

+5
source share
1 answer

The short answer is yes, the object reference is stored as a pointer, such as C.

I'm not sure what you mean by being saved as an "integer", but if you want to do some operation on them, how can you do in C (for example, add an integer to the pointer, etc.), you can't with java.

Otherwise, it is almost the same, except that it is handled by Java.

JLS 4.3.1 indicates that an object reference is stored as a pointer:

Control values ​​(often only links) are pointers to these objects and a special null reference that is not related to the object.

+3
source

All Articles