This generic question in Java may look confusing to any one who is not very familiar with Generics as in first glance it looks like String is object so List<String>
can be used where List<Object>
is required but this is not true. It will result in compilation error.
It does make sense if you go one step further because List<Object>
can store anything including String
, Integer
etc but List<String>
can only store Strings
.
Also have a look at: Why not inherit from List<T>?