First explanation:
If you define a List of Objects, than you state, that this List can contain anything you want. (This is some additional information you provide.)
If you define a List of Strings, than this is NOT a List of anything. It is a List of Strings.
A List of Strings is not the same as a List of Objects.
Technical explanation:
Let's say you have a class like this:
class Machine<T> {
void process(T input) {
...
}
}
If you then create an instance: new Machine<String>()
, than the compiler knows, that your new object is ment to process Strings. It will fail if you want to make it process a Number, an Array or anything else.
If you create a more general machine, but calling new Machine<Object>()
, than the compiler knows, that Strings, Numbers, Arrays and any kind of stuff can be processed by that machine.
The compiler will not allow you to cast the specific String-Machine (new Machine<String>()
) to a general Object-Machine (Machine<Object>
), because this would allow you to let it process Numbers, Arrays, etc. for what it was not meant for.