Qual è il tipo corretto di argomento per il metodo addAll (..) nelle raccolte Java? Se faccio qualcosa del genere:java generics e il metodo 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);
Capisco che ho bisogno di inizializzare entrambe le variabili. Tuttavia, ottengo un errore di compilazione (da eclissi):
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[]>>)
cosa sto facendo male?
È possibile modificare per mostrare le dichiarazioni sia per "currentList" che per "newElements"? – elduff
Penso che "newElements" dovrebbe essere "addAll" Ho corretto il codice. – Jherico