Languagemedium0-2 years

What is the difference between int and Integer? Where does autoboxing bite?

int is a primitive value: fast, never null, no identity. Integer is an object: nullable, allocated, compared with equals. Autoboxing converts silently — and unboxing a null Integer throws a NullPointerException, often inside an arithmetic expression far from the field.

The lesson behind it →
More on Language