Finding the Length of a String within an ArrayList
<p>I am writing a CSVParser program that seperates words at commas. I am currently trying to find and record the longest word that appears in the file. Here is my class.</p>

<pre><code>import csv.CSVParser;
import java.io.*;
import java.util.*;

public class RecordFormatter {

public static void main (String[] args) {
       CSVParser parser = new CSVParser(new File (args[0]));
       while (parser.hasNextLine()) {
              ArrayList&lt;String&gt; ls = parser.getNextLine();
              for (int i = 0; i&lt;ls.size(); i++) {
                   System.out.print("|" + ls.get(i) + " ");
                   }
              System.out.print("|");
              System.out.println();
       }
      CSVParser parser1 = new CSVParser(new File (args[0]));
      ArrayList&lt;Integer&gt; maxCol = new ArrayList&lt;Integer&gt;();
      while (parser1.hasNextLine()) {
            ArrayList&lt;String&gt; ls1 = parser1.getNextLine();
            for (int i = 0; i&lt;ls1.size(); i++) {
                 maxCol.add(ls1.get(i)); //Here is where my bug occurs.
            }
      }

}

}
</code></pre>

<p>I have created two CSVParsers and am trying to use the second of the two to record the length. I tried (as you can see above) storing the int length value of each word into another Arraylist, but I can't seem to get it to work. Any help would be much appreciated.</p>
