0

One thing my professor failed to explain was whether or not wrapper classes (such as Integer.* or Double.*) took up more RAM space because they have the format of an object reference and not a primitive data type.

1 Answers1

1

Yes, boxed typed take more space because - of the pointer referencing it (often 64-bit on modern, non-embedded architectures) - of the extra fields in the native implementation of the Object (such as, possibly, reference to the class, id, etc.)

However, under the hood, at least in theory, JVM/Hotspot may be able to optimize some boxed types based on their utilization.

Roberto Attias
  • 1,883
  • 1
  • 11
  • 21