how elements total wildcard general collection?


why i compiler errors java code?



1  open list<? extends foo> getfoos()
2 {
3 list<? extends foo> foos = new arraylist<? extends foo>();
4 foos.add(new subfoo());
5 relapse foos;
6 }


where 'subfoo' petrify category implements foo, foo an interface.



errors i code:




  • on line 3: "cannot instantiate arraylist<? extends foo>"

  • on line 4: "the slight add(capture#1-of ? extends foo) form list<capture#1-of ? extends foo> convenient arguments (subfoo)"



update: interjection jeff c, i change line 3 contend "new arraylist<foo>();". nonetheless i'm still carrying emanate line 4.



Comments

Popular posts from this blog

list macos calm editors formula editors

how hibernate @any-related annotations?

why does floated <input> control floated component slip over too distant right ie7, nonetheless firefox?