Created
January 20, 2020 23:06
-
-
Save parzibyte/cc44f804234680a34c7937927842effb to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
int[] numeros = { 1, 2, 3, 1, 1, 2, 3, 4, 2, 4, 412, 3, 12, 321, 12, 3, 213, 13, 213121, 1, 345, 12, 312, 3, 5424, | |
314 }; | |
System.out.printf("El arreglo es: %s\n", Arrays.toString(numeros)); | |
HashMap<Integer, Integer> mapa = new HashMap<>(); | |
for (int x = 0; x < numeros.length; x++) { | |
int numero = numeros[x]; | |
if (mapa.containsKey(numero)) { | |
mapa.put(numero, mapa.get(numero) + 1); | |
} else { | |
mapa.put(numero, 1); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment