Luigi Plinge wrote:...the same thing happens with the auto-boxing in Arraylists... this one's more confusing because Integer objects aren't even mentioned...
Unlike arrays, Collections (like Lists) cannot hold primitive values. This is why the autoboxing happens.
Although this will compile and run without mentioning Integer types, you will probably see compiler warnings about unchecked or unsafe operations. Since
Java 5, the safer way is to specify a type for the Collection...
...this allows the compiler to insert all the necessary casting
and avoid surprises about what your Collection actually contains.