Java Array Exception
<p>Help ending array, I keep getting Exception in thread "main" java.lang.ArrayIndexOutOfBoundsException: 13. I try to end searching with &amp;&amp; but it goes back to searching root. I need some ideas or any help on fixing this would be good!</p>

<pre><code>import java.io.*;
import java.util.Collections;
import java.util.List;
import java.util.ArrayList;

public class Root_Words {    
    public static void main(String[] args) {
        String Word;

        List&lt;String&gt; xList = new ArrayList&lt;String&gt;();
        try{
            BufferedReader reader = new BufferedReader(new FileReader("Words.txt"));
            while ((Word = reader.readLine()) != null) {
                xList.add(Word);
            }
        }
        catch (IOException ioe){
            System.out.println("Problem opening input file");
        }

        String[] Words = new String[ xList.size() ];
        Collections.sort(xList);
        xList.toArray( Words );

        int c;
        String roots = "";

        for( int i = 0; i &lt; Words.length; i++ ){
            c = root(Words[i],Words[i+1]);

            if(c &gt;= 3 || c &lt;=5 ){
                roots = Words[i];
                System.out.printf("%s\n", roots);

                while(Words[i].startsWith(roots) &amp;&amp; i &lt; Words.length){
                    System.out.printf("%s\n", Words[i]);
                    i++;
                }
                i--;
            }
        }
    }
    public static int root(String a, String b){
        int min;

        if(a.length() &lt; b.length() ){
            min= a.length();
        }
        else{
            min = b.length();
        }
        //return min;

        int i;

        i = 0;
        while (i &lt; min)
        {
            if (a.charAt(i) == b.charAt(i))
                i++;
            else break;

        }

        return i;


    }
}
</code></pre>
