Is there any difference in below two?
Code:
List<? extends Object> ls = new ArrayList<String>();
List<?> ls1 = new ArrayList<String>();
List<? extends Object>
and
List<?>
Both are same. Because collections doen't allow primitives and only Classes
,in java every Class
implicitly extends Object
.
You can see the difference If you write List<? extends MyOwnParentClass>
.
But with Object
, you won't get any extra benefit/loss here.