Reputation: 12316
I have this Method():
private List<? extends Map<String, String>> creaListaDeGrupos() {
ArrayList resultado_padre = new ArrayList();
for (int i = 0; i < listadoPartidas.getPartidas().size(); i++) {
HashMap<String, String> padre = new HashMap<String, String>();
padre.put("posicionLista", posicionlista.get(i));
padre.put("codigo", codigoBaremo.get(i));
padre.put("descripcionBaremo", descripcionBaremoPadre.get(i));
padre.put("cantidad", cantidad.get(i));
padre.put("importe", importe.get(i));
padre.put("estado", estado.get(i));
padre.put("observaciones", observaciones.get(i));
resultado_padre.add(padre);
}
return resultado_padre
}
And Lint return me the error:
ArrayList is a raw type. References to generic type ArrayList should be parameterized
But i cant do
ArrayList<String> resultado_padre = new ArrayList();
Because this isnt a arraylist of strings, what type bust will be?
Upvotes: 4
Views: 6786
Reputation: 61558
You could try creating the same type you are returning:
List<HashMap<String, String>> = new ArrayList<HashMap<String, String>>();
There is no need to declare the implementation type, i.e. ArrayList
. The List
interface is more general, so when declaring variables as a concrete type, ask yourself if this is necessary. See
Programming against interface
Upvotes: 2
Reputation: 1472
private List<Map<String, String>> creaListaDeGrupos() {
List<Map<String, String>> resultado_padre = new ArrayList<Map<String, String>>() ;
for (int i = 0; i < listadoPartidas.getPartidas().size(); i++) {
Map<String, String> padre = new HashMap<String, String>();
padre.put("posicionLista", posicionlista.get(i));
padre.put("codigo", codigoBaremo.get(i));
padre.put("descripcionBaremo", descripcionBaremoPadre.get(i));
padre.put("cantidad", cantidad.get(i));
padre.put("importe", importe.get(i));
padre.put("estado", estado.get(i));
padre.put("observaciones", observaciones.get(i));
resultado_padre.add(padre);
}
return resultado_padre
}
Upvotes: 0