What is the size of reference variables in java? I am quite sure it wont be dependent upon the architecture or is it? Does it bear any resemblance with concept of pointers in C? I have tries but could not get any convincing answer.
It depends on OS version in windows. The size of the reference itself will depend on your processor architecture - 4 bytes on 32-bit, 8 bytes on 64-bit. The reference itself is basically a pointer. 32 bits on a 32 bit OS, 64 bits on a 64 bit OS.
Reference variable is used to point object/values. 2. Classes, interfaces, arrays, enumerations, and, annotations are reference types in Java. Reference variables hold the objects/values of reference types in Java.
why reference size is always 4 bytes - c++
Yes, two or more references, say from parameters and/or local variables and/or instance variables and/or static variables can all reference the same object.
The amount of memory used by a reference depends on several parameters:
-XX:-UseCompressedOops
, they will use 64 bits.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