Created
June 7, 2018 10:34
-
-
Save SergiyOsadchyy/3987b03eaaf42d53273103071566d2b2 to your computer and use it in GitHub Desktop.
Java_HashMap
This file contains hidden or 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
| public class Dict { | |
| public static void myFunc(int[] inArray) { | |
| HashMap<Integer, Integer> dict = new HashMap<Integer, Integer>(); | |
| for (int i = 0; i < inArray.length; i++) { | |
| if (dict.get(inArray[i]) != null) { | |
| dict.put(inArray[i], (dict.get(inArray[i]) + 1) ); | |
| } | |
| else { | |
| dict.put(inArray[i], 1); | |
| } | |
| } | |
| System.out.println(Arrays.asList(dict)); | |
| } | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment