title: Write a program that will read a line of text, and will display all letters in the text along with the number of times the letter appears in the text
body: <p>I have the basics, but I need to make it so that my program will work without printing the unused letters of the alphabet at the end, say my sentence is "dog" I would want the output to be: D-1
                                 O-1
                                 G-1, instead of A-0 B-0 D-1, and so on. Thanks for any help provided, it is greatly appreciated.</p>
  
  <p>what I have so far is:</p>
  
  <pre><code>package as10;
  
  import java.util.*;
  
  public class as
  {
  
  private static void countLetters(String sentenceString) 
  {
      int[] array = new int[26];
      sentenceString = sentenceString.toUpperCase();
  
      for (int i = 0; i &lt; sentenceString.length(); ++i) 
      {
          if (sentenceString.charAt(i) &gt;= 'A' &amp;&amp; sentenceString.charAt(i) &lt;= 'Z') 
          {
              ++array[sentenceString.charAt(i) - 'A'];
          }
      }
  
      for (int i = 0; i &lt; 26; ++i) 
      {
          System.out.println((char) ('A' + i) + " - " + array[i]);
      }
  }
  
  public static void main(String[] args) 
  {
      Scanner kbd = new Scanner(System.in);
      String letterString;
      while (true) 
      {
          System.out.println("Enter a line of text: ");
          letterString = kbd.nextLine();
  
          System.out.println("Letter Frequencies: ");
          countLetters(letterString);
  
          break;
      }
      kbd.close();
  }
  }
  </code></pre>