0

Wrapper Classes

Why does the arraylist want the wrapper class? ArrayList<int> list = new ArrayList<int>(); ArrayList<Integer> list = new ArrayList<Integer>();

21st Dec 2017, 1:27 PM
Richard Harding Jr
1 Respuesta
0
It has to do with implementation. The List is designed to work with objects, not primitive types. There simply is no way to create a container that can contain any primitive type or object in Java. But it doesn’t matter as long as you remember to use Integer instead of int.
1st Jan 2018, 1:59 AM
Alexander
Alexander - avatar