Jaki jest poprawny typ argumentu metody addAll (..) w kolekcjach Java? Jeśli zrobię coś takiego:Generics java i metoda addAll
List<? extends Map<String, Object[]>> currentList = new ArrayList<Map<String, Object[]>>();
Collection<HashMap<String, Object[]>> addAll = new ArrayList<HashMap<String, Object[]>>();
// add some hashmaps to the list..
currentList.addAll(addAll);
Rozumiem, że muszę zainicjować obie zmienne. Dostaję jednak błąd kompilacji (od eclipse):
Multiple markers at this line
- The method addAll(Collection<? extends capture#1-of ? extends Map<String,Object[]>>) in the type List<capture#1-of ? extends Map<String,Object[]>> is not applicable for the arguments (List<capture#2-of ? extends
Map<String,Object[]>>)
- The method addAll(Collection<? extends capture#1-of ? extends Map<String,Object[]>>) in the type List<capture#1-of ? extends Map<String,Object[]>> is not applicable for the arguments
(Collection<HashMap<String,Object[]>>)
co robię źle?
Czy możesz edytować, aby pokazać swoje deklaracje dla "currentList" i "newElements"? – elduff
Myślę, że "newElements" ma być "addAll" Naprawiłem kod. – Jherico