title: Map column values in TreeMap as key with line number as values
body: <p>I want to read a column of numbers from a file in java. For example:</p>
  
  <pre><code>945
  922
  922
  480
  480
  819
  819
  289
  386
  </code></pre>
  
  <p>and I want to put these numbers in a <code>TreeMap</code> as keys. The value for each key will be the number of its line. Therefore, the map will have something like this:</p>
  
  <pre><code>{(945:1),(922:2,3),(480:4,5)}
  </code></pre>
  
  <p>I am trying the above, but I get an error.</p>
  
  <pre><code>ArrayList&lt;Integer&gt; clusterNums = new ArrayList&lt;&gt;();
  String clusterLine;
  TreeMap&lt;Integer, ArrayList&lt;Integer[]&gt;&gt; clusterMap = new TreeMap&lt;Integer, ArrayList&lt;Integer[]&gt;&gt;();
  while ((clusterLine = clusterFile.readLine()) != null) {
                  clusterNums.add(Integer.parseInt(clusterLine));
               }
  for (int i = 1; i &lt; clusterNums.size(); i++){
        if (!clusterMap.containsKey(clusterNums.get(i-1))) {
             clusterMap.put(clusterNums.get(i-1), new ArrayList&lt;Integer[]&gt;());
           }
        clusterMap.get(clusterNums.get(i-1)).add(i);
   }
  </code></pre>
  
  <p>Could you please advise me?</p>
  
  <p>Thanks.</p>