Wrapper classes are used in Java Collections because collections can store only objects, not primitive data types. Wrapper classes convert primitive values into objects, allowing them to be stored and processed within collection classes.
An ArrayList cannot store int values directly, so Integer objects are used instead.
import java.util.ArrayList;
import java.util.List;
public class Demo {
public static void main(String[] args) {
List<Integer> numbers = new ArrayList<>();
numbers.add(100); // Autoboxing
int value = numbers.get(0); // Unboxing
System.out.println(value);
}
}A concise interview answer is
We use wrapper classes in collections because the Java Collections Framework stores only objects, not primitive data types. Wrapper classes such as Integer and Double allow primitive values to be stored in collections, and Java automatically handles conversions through autoboxing and unboxing.
Last updated: 11 November 2026
Previous question: Why do we need wrapper classes?
Next question: What is the difference between autoboxing and unboxing in Java?