I am taking data structures and analysis. We have gone over how assignment and comparisons of object types is much slower than assignment and comparisons for basic types, such as int.
I recall learning C (all those almost thirty years ago) and how pointers in C are (or were) integer calls. Is Java similar today, is a reference to an instanced object internally an integer address of memory, and as such are comparisons such as
if (MyObject != null) {...}
an integer operation within the framework?
I hope my question is clear. I've been researching around and I can't find a clear answer of how Java manages its dynamic memory.
The short answer is yes, a reference to an object is stored as pointer like it is in C.
I am not sure what you mean by stored as "integer", but if what you want is to do some operation on them like you can do in C (e.g. add integer to a pointer, etc.), then you can't with Java.
For the rest, it's pretty much the same except that it is handled by Java.
JLS 4.3.1 specifies that a reference to an object is stored as pointer:
The reference values (often just references) are pointers to these objects, and a special null reference, which refers to no object.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With