Título: Problema con HashMap Publicado por: ferchundo9 en 27 Diciembre 2017, 17:26 pm Como podría iterar un hashmap y realizar eliminaciones de elementos del mismo dentro del bucle?
Título: Re: Problema con HashMap Publicado por: XafiloX en 27 Diciembre 2017, 18:46 pm Mira la documentación sobre entrySet (https://docs.oracle.com/javase/7/docs/api/java/util/HashMap.html#entrySet() (https://docs.oracle.com/javase/7/docs/api/java/util/HashMap.html#entrySet())).
Citar Returns a Set view of the mappings contained in this map. The set is backed by the map, so changes to the map are reflected in the set, and vice-versa. If the map is modified while an iteration over the set is in progress (except through the iterator's own remove operation, or through the setValue operation on a map entry returned by the iterator) the results of the iteration are undefined. The set supports element removal, which removes the corresponding mapping from the map, via the Iterator.remove, Set.remove, removeAll, retainAll and clear operations. It does not support the add or addAll operations. Título: Re: Problema con HashMap Publicado por: rub'n en 28 Diciembre 2017, 21:16 pm Testea a ver :xD
Código
Salida en consola Código |