0
Hashmap and arraylist
How do I add an arraylist to a hashmap in java when the key is name of the objects in arraylist?
1 Resposta
+ 1
if class Obj has String name; field then
for (Obj o : array) map.put(o.name, o);
//or
array.forEach(o -> map.put(o.name, o) );