Autoboxing converts primitives to wrappers (e.g., `int`→`Integer`) and unboxing does the reverse. Pitfalls: unboxing `null` causes NPE, `Integer` caching can confuse `==`, and extra allocations can hurt performance in hot code.
Integer x = null;
// int y = x; // NullPointerException due to unboxing
Integer a = 100;
Integer b = 100;
System.out.println(a == b); // true (Integer cache)
Integer c = 1000;
Integer d = 1000;
System.out.println(c == d); // falseAutoboxing/unboxing is compiler-generated conversion between primitives and wrapper types.
Where it shows up:
Integer x = null;
int y = x; // NPEInteger a = 127, b = 127; // cached
Integer c = 128, d = 128; // usually not cached
System.out.println(a == b); // true
System.out.println(c == d); // false