Let's look at the first example. Think about the operations you must perform in List<Object>: add, delete, and retrieve any object.
You are trying to populate these requirements with a collection that allows you to add, delete, and retrieve only rows.
List<Object> myList = new ArrayList<String>();
myList.add(new MyClass());
Secondly, simply because Generics in Java do not support primitive types. For more information, you can check:
java - Why primitive types are not supported in Generics?
source
share