Boxed Number
A boxed number, such as this instance of Integer, is nice
because it can be treated as an object and has useful methods.
However:
- Integer has the same numeric accuracy as an int,
32 bits.
- Integer takes 4 to 6 times as much storage as an int.
- Integer is immutable:
since it is possible that multiple variables point to it, we cannot
change its value.
- Doing arithmetic (even ++) may require creation of a new box
(allocation of new storage), often making the old box garbage.
(Java has special techniques to make small Integer
values more efficient.)
- Boxes are somewhat expensive because they must be
garbage collected. The garbage collector is a highly paid worker.
Contents   
Page-10   
Prev   
Next   
Page+10   
Index