Counting the frequency of alphabet letters in a String
<p>After counting the frequency of letters that appear in a particular string, I am trying to store these values in an <code>int</code> array. The array has 26 values in total for the whole alphabet. The int variable <code>frequency</code> is used as counter to capture the frequency of each letter in the string, but the count is miscalculated. What am I doing wrong?</p>

<pre><code>int frequency = 0;
char character;
alphaCounts = new int[26];

for (int i = 0; i &lt; alphabet.length; i++) {
    frequency = 0;
    for (int j = 0; j &lt; stringInput.length(); j++) {
        character = stringInput.charAt(j);
        if (character == alphabet[i]) {
            frequency++;
        }
    }

    System.out.println(alphabet[i] + "\t\t" + frequency);

    // Populating alphaCounts array with the freq values
    alphaCounts[i] = frequency;
    i++;
    System.out.print("\n" + "alphaCounts: " + alphaCounts[i]);
}
</code></pre>