Converting an array of 26 integers to char's (alphabet)
<p>I am using the java scanner to input strings of text from the keyboard then having my program create a table that outputs a-z and displaying the number of each letter found within the inputted string. (letter frequencies)</p>

<p>My driver/main class</p>

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

public class LetterDriver{
  public static void main(String[] args){
    Scanner s = new Scanner(System.in);
    LetterProfile profile = new LetterProfile();
    String tScan = " ";
    int numReturns = 0;
    while(numReturns &lt; 2){
      tScan = s.nextLine();
      if (tScan.length() == 0){
        numReturns++;
      }
      else{
        profile.countChars(tScan);
        numReturns = 0;
      }
    }
    profile.printResults();

  }

}
</code></pre>

<p>My Profile class</p>

<pre><code>public class LetterProfile {
  int score[] = new int [26];

   public void countChars (String s) {
    s = s.toLowerCase();
    char a = 'a';
    for (int i = 0; i &lt; s.length(); i++) {
      int next = (int)s.charAt(i) - (int) a;
      if ( next&lt;=26 &amp;&amp; next &gt;= 0)
        score[next]++;


    }
 }

    public int largestLength() { 
      int largest = 0;
      int largestindex = 0;
      for(int a = 0; a&lt;26; a++) {
        if(score[a] &gt; largest) {
        largest = score[a];
        largestindex = a;

      }
      }
      return (char)largestindex;

    }


    public void printResults() {
       largestLength();

      System.out.println(("Most Frequent") + (" :") + largestLength());
    }
}
</code></pre>

<p>The program compiles, when I run it it allows me to put my input in but the only output it gives me is the most frequently used letter in the form of a number (since my array is 0-25, with 0 = a, 1 = b)</p>

<p>Basically what I'm having trouble trying to do is having my code output a table of a-z while displaying the letter frequencies beside it. Is there a simple way of getting this done?</p>

<p>Thanks.</p>
