autoboxing and unboxing are features that automatically convert between primitive types (like int
, char
, double
) and their corresponding wrapper classes (Integer
, Character
, Double
, etc.).
🧠Autoboxing
This is when Java automatically converts a primitive type into its wrapper class.
Example:

🔄 Unboxing
This is when Java automatically converts an object of a wrapper class back into a primitive type.
Example:

These features make your code cleaner and more intuitive, especially when working with collections like ArrayList
, which can’t store primitives directly.