title: Storing ArrayList<Integer> as key in TreeMap Java
body: <p>I am storing an arrayList as my keys in a TreeMap but I am getting this exception</p>
  
  <p><strong>java.lang.ClassCastException: java.util.ArrayList cannot be cast to java.lang.Comparable</strong></p>
  
  <p>I copy the content of array to ArrayList and try to store that arrayList as my keys in the Map
  My Code is :</p>
  
  <pre><code>TreeMap&lt; ArrayList&lt;Integer&gt; , Integer &gt; bandsMap = new TreeMap&lt; ArrayList&lt;Integer&gt; , Integer &gt;(); 
  ArrayList&lt; Integer &gt; erfcn = new ArrayList&lt; Integer &gt;();
  
  for (int index = 0; index &lt; frequencies.length; index++)   
      erfcn.add(frequencies[index]);
  
      bandsMap.put( erfcn , band_number);
  
   for (Integer value : bandsMap.values()) {
      System.out.println("Value = " + value + "\n");
   }
  </code></pre>
  
  <p>Any Idea ? 
  Thanks</p>