Simply put, because int is a basic type and does not contain the methods required in the collection framework. Take this as an example. Even hashCode is not implemented. How to calculate the hash value? So you need to use Integer.
The types in generics must be subclasses of Object.
The type parameters in generics must be a subclass of Object, so int cannot be used, but the wrapper type Integer of int should be used.
int is a basic data type, so it won’t work; you should use its corresponding packaging class, Interger
Simply put, because int is a basic type and does not contain the methods required in the collection framework. Take this as an example. Even hashCode is not implemented. How to calculate the hash value? So you need to use Integer.
The types in generics must be subclasses of Object.
int is the data type, and Integer is the packaging class. What should be placed in generics is the object type