title: Inputting Arrays into a Hashmap
body: <p>I feel like this is a very simple question, but I couldn't find an answer. </p>
  
  <p><strong>Can you input an array object to the put method of a HashMap?</strong></p>
  
  <p>Example:</p>
  
  <p>Say you have a HashMap:<br>
  <code>HashMap&lt;Integer, String&gt; map = new HashMap &lt;Integer, String&gt;();</code></p>
  
  <p>You have an array of integers and an array of strings conveniently given. The arrays are not initialized as shown below, but contain unknown values (this is just easier for illustrating the result).</p>
  
  <pre><code>int[] keys = {1, 3, 5, 7, 9};
  String[] values = {"turtles", "are", "better", "than", "llamas"};
  </code></pre>
  
  <p>I want the key-value pairs of the HashMap to be:</p>
  
  <pre><code>1, turtles
  3, are
  5, better
  7, than
  9, llamas
  </code></pre>
  
  <p>Can this be achieved with something like <code>map.put(keys, values)</code>? I know this doesn't work, you should get an error like "<em>The method put(Integer, String) in the type HashMap is not applicable for the arguments (int[], String[])</em>". I just want something more efficient, elegant, or compact than:</p>
  
  <pre><code>for (int i=0; i &lt; keys.length; i++) {
      map.put(keys[i],values[i]);
  }
  </code></pre>