Autoboxing was added in Java 1.5 as a means of converting between primitives and their object wrappers, and back again. The transformation is done by the Java compiler using the valueOf, xxxValue methods.
Examples –
[sourcecode language=”java”] Integer i = 10;i = i + 10;
[/sourcecode]
So this is great news because you can stop using primitives? Not quite – you still incur an overhead on object creation –
[sourcecode language=”java”] Integer total = 0;The compiler would generate code similar to –
[sourcecode language=”java”] Integer total = 0;