How would I capitialize the first letter of a sentence in Java?
<p>I tried splitting up the words in the line and checking if they had periods, but I got an error: </p>

<pre><code>falls.falls.falls.Exception in thread "main" java.lang.ArrayIndexOutOfBoundsException: 6
at Alpha.main(Alpha.java:10)     
</code></pre>

<p>Code:</p>

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

public class Alpha
{
    public static void main(String[] args)
    {
        String phrase = "the moon falls. the flowers grew.";
        String beta = "";
        String[] array = phrase.split(" ");
        for (int i = 0; i &lt; array.length; i++)
        {
            if (array[i].endsWith("."))
            {
                array[i + 1] = array[i + 1].substring(0, 1).toUpperCase() + array[i + 1].substring(1);

                beta = beta + array[i];
            }
            System.out.print(beta);
        }
    }
}
</code></pre>

<p>(Also I don't think that's how I would call another word of an array, any suggestions on how I can fix that?)</p>
