title: Compare maps with char array as values - Java
body: <p>I'm playing around with hashmaps right now. I'm trying to figure out how to compare the values of two hashmaps - when the values of each hashmap is a char array. I've looked around found a couple of methods that might work -I'm just not sure how to implement properly. Basically I have two maps with different keys but the same value. I want to iterate thru one of the maps and create a boolean value that returns true if they have the same value. If someone could help me figure this out, that would be great. My code is below with what I've tried thus far:</p>
  
  <pre><code>publipublic class MapExample {
  
  public static void main(String[] args) {
  
      Map&lt;String, char[]&gt; map1 = new HashMap&lt;String, char[]&gt;();
      Map&lt;String, char[]&gt; map2 = new HashMap&lt;String, char[]&gt;();
  
      char[] letters1 = new char[3];
      letters1[0] = 'a';
      letters1[1] = 'b';
      letters1[2] = 'c';
  
      char[] letters2 = new char[3];
      letters2[0] = 'x';
      letters2[1] = 'y';
      letters2[2] = 'z';
  
      map1.put("1", letters1);
      map1.put("2", letters2);
      map1.put("3", letters1);
  
      map2.put("4", letters1);
  
      Set s = map1.entrySet();
      Iterator it = s.iterator();
  
      boolean containsValue;
  
      //I've tried this but it produces false (and infinite loop) when maps have the same value
      while (it.hasNext()) {
  
          containsValue = map1.equals(map2.values());
          System.out.println(containsValue);
      }
  
      //I've tried this too, but can't seem to adjust the lists to accept char[]
      /*
      List&lt;String&gt; values1 = new ArrayList&lt;String&gt;(map1.values());
      List&lt;String&gt; values2 = new ArrayList&lt;String&gt;(map2.values());
      Collections.sort(values1);
      Collections.sort(values2);
      boolean mapsHaveEqualValues = values1.equals(values2);*/
  
  }
   }
  </code></pre>