Nouvelle formation ! Tous les codeurs devraient apprendre l'IA générative !
Essayez une leçon gratuite0
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 Réponse
+ 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) );