☕ Java
Beginner
What is the difference between int and Integer in Java?
Answer
int is a primitive data type that stores a 32-bit signed integer value directly. It cannot be null, cannot be used as a generic type parameter, and is more memory-efficient. Integer is the wrapper class for int — an object that wraps the primitive value. It can be null, can be used in collections (like List<Integer>), and provides utility methods like Integer.parseInt(), Integer.MAX_VALUE. Java automatically converts between them via autoboxing (int → Integer) and unboxing (Integer → int).
Previous
What are the eight primitive data types in Java?
Next
What is autoboxing and unboxing in Java?