What is Auto-boxing and Unboxing, and does it impact performance?

1 answers

Autoboxing is the process of automatic conversion (by the Java compiler) from the primitive type to the corresponding object type (wrapper class of the primitive type). Unboxing is the reverse process, the conversion from the object type to the primitive type. Some primitive-object type pairs are (int, Integer), (long, Long), (double, Double) etc.

Since there's additional work required to execute them, both autoboxing and unboxing have an impact on the performance, so the developer should be careful and identify the points where autoboxing/unboxig happens to take care of some optimizations if needed.

shilpigupta22 shilpigupta22 [Author] 4 months ago votes 0