Boxing
Boxing is the conversion of a value, typically a primitive or value type, into an object or reference representation, either explicitly or implicitly.
100 Java Mistakes and How to Avoid Them
A boxing conversion converts a Java primitive value to an object of its corresponding wrapper type, either explicitly or implicitly.
- How it is used
- Prevents failures and misleading behavior caused by implicit primitive-wrapper conversions in expressions, comparisons, tests, and collections.
- How deep it goes
- Explains implicit valueOf and primitive-value conversions through conditional-expression failures, caching behavior, and signed-zero consequences.
- Examples
- Uses a mixed Double/double conditional, cached Integers, a malformed JUnit assertion, and Double values for positive and negative zero.
- What you can do after
- Diagnose/debug with it by exposing implicit conversions, avoiding null unboxing, and replacing wrapper identity checks with content comparisons.
Read how 100 Java Mistakes and How to Avoid Them explains boxing →
Clojure: The Essential Reference
Autoboxing is the implicit conversion of primitive values to object representations and, where applicable, the reverse conversion.
- How it is used
- Explains surprising reference-identity results when Clojure compares primitive values through Object-based calls.
- How deep it goes
- Traces implicit boxing into generated Object arguments and contrasts it with constructors, cached valueOf calls, and variable bindings.
- Examples
- Uses 100 and 1000 Long values, def and let bindings, Long constructors, and Long/valueOf to expose identity differences.
- What you can do after
- Diagnose reference-identity surprises caused by boxing and choose value-based comparison when equivalence is intended.
Kotlin in Action, 2E
Boxing is the representation of a primitive value as an object instance such as java.lang.Integer.
- How it is used
- Explains how Kotlin array choices support Java interoperability and efficient primitive storage.
- How deep it goes
- Distinguishes boxed and primitive array representations, then stops short of broader boxing rules outside arrays.
- Examples
- Uses Array<Int>, IntArray, intArrayOf, and zero-filled primitive-array examples.
- What you can do after
- Apply it by selecting Array<Int> for object-array compatibility or IntArray for unboxed primitive storage.
Related concepts
- dynamic typingused by · Dynamic typing is a typing discipline in which type information and checks are determined primarily at runtime rather than fixed statically for variables.
- primitive arraycontrasts with · A primitive array is an indexed collection whose elements are stored as values of a primitive type rather than references to objects.
- unchecked operatorscontrasts with · Unchecked operators are Clojure numeric functions that perform basic arithmetic without integer overflow checks and accept restricted numbers of arguments.
These guides are generated from the text of Manning books by Manning's knowledge graph and link to the sections they draw on. The full books are available on liveBook and at manning.com.


