This content has been marked as final. Show 3 replies
That's not type safe. If you'd kept another reference to the list as List<Foo>() then insert an item of class Bar, or another subclass thereof, the the List<Foo> reference would contain an item which wasn't of class Foo.
This is where "bounds" come in.
This creates a list reference which can contain a list of any subclass of Bar. It will, however, be effectively read-only.
List<Foo> lfo = new ArrayList<Foo>(10); List<? extends Bar> baz = lfo; baz.add(new Bar()); .... compilation error