The wrapper class is used to convert primitive types to objects. Since ArrayList is a generic class, it can only interact with objects, which is why wrapper classes for primitive types are used.
ArrayList<Integer> list = new ArrayList<>();
list.add(1);//autoboxing
int first = list.get(0);//unboxing
Comments
Leave a comment