Skip to content

Instantly share code, notes, and snippets.

@domgetter
Created December 28, 2015 02:48
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save domgetter/93609123c0b8155220e8 to your computer and use it in GitHub Desktop.
Save domgetter/93609123c0b8155220e8 to your computer and use it in GitHub Desktop.
int[] numbers = {1, 2, 3, 4};
HashMap myMap = new HashMap();
for(int i; i < numbers.length(); i++) {
myMap.put(numbers[i], numbers[i]*numbers[i]);
}
// You will get a HashMap that looks like this: {1: 1, 2: 4, 3: 9, 4: 16}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment