java génériques et de la méthode addAll

Est-ce le bon type de l'argument de la addAll(..) la méthode en Java collections? Si je fais quelque chose comme ceci:

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); 

Je comprends que j'ai besoin d'initialiser les variables. Cependant, je reçois une erreur de compilation (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[]>>)

ce que je fais mal?

  • Pouvez-vous modifier pour afficher vos déclarations pour à la fois "currentList" et "newElements'?
  • Je pense que "newElements' est censé être "addAll' j'ai corrigé le code.
InformationsquelleAutor neesh | 2010-04-23