title: Occurrences of each letter
body: <p>this is the program that I have to write but I get this error, </p>
  
  <pre><code>Exception in thread "main" java.lang.ArrayIndexOutOfBoundsException:
  50
  </code></pre>
  
  <p>Write a complete program using two arrays, upper and lower to keep the upper
  And lower alphabet respectively.
  Ask the user to enter string example:</p>
  
  <blockquote>
    <p>This is a test  from  Jupiter. Soon you will see who is from
    Jupiter!!! May be Dr. D.</p>
  </blockquote>
  
  <p>Your program should parse the string and keep track of number of alphabet. Both arrays are indexed from 0 to 25. The logical way to do this is to use upper[0] to
  Count the number of ‘A’, and upper[1] to count number of ‘B’ and so on. Likewise
  For the lower array.</p>
  
  <p>Output should look like:</p>
  
  <pre><code>A: 0 a:2
  
  B: 0 b:0
  .
  .
  .
  Z:0 z:0
  </code></pre>
  
  <h2>Code</h2>
  
  <pre><code>import java.awt.*;
  import javax.swing.*;
  import java.io.*;
  import java.util.*;
  
  public class Letter {
    public static void main(String[] args) {
  
      // this is get results
      char[] chars = userEnters();
  
      System.out.println();
      System.out.println("Occurrences of each letter are:");
      PrintArray(countLow(chars), countUp(chars));
    }
  
    public static char[] userEnters() {
  
      String inputX = JOptionPane.showInputDialog("Enter line of text:  ");
      char[] chars = inputX.toCharArray();
  
      return chars;
    }
  
    public static int[] countLow(char[] input) {
      int[] counts = new int[26];
  
      for (int i = 0; i &lt; input.length; i++) {
        counts[input[i] - 'a']++;
      }
      return counts;
    }
  
    public static int[] countUp(char[] input2) {
      int[] countsUp = new int[26];
      for (int i = 0; i &lt; input2.length; i++) {
        countsUp[input2[i] - 'A']++;
      }
      return countsUp;
    }
  
    public static void PrintArray(int[] counts, int[] countsUp) {
      for (int i = 0; i &lt; counts.length; i++) {
  
        System.out.print(counts[i] + " " + (char) ('a' + i) + " ");
        System.out.print(countsUp[i] + " " + (char) ('A' + i) + "\n");
      }
    }
  }
  </code></pre>