title: Loop through char array and count chars
body: <p>I'm trying to optimize my Java code so I try things. In my search for a short way I produced the code here below. This throws an <code>Exception</code>. Can you tell me why? Can't I loop through a string by a char Array?</p>
  
  <pre><code>public class Input {
  
      public static void main(String[] args) {
  
          String check = "Dit moet toch gewoon te doen zijn !!";
          check = check.toLowerCase();
  
          int[] counter = {0, 0, 0, 0, 0};
          char[] vowel = {'a', 'e', 'i', 'o', 'u'};
  
          int total = 0;
          for (int i = 0; i &lt; check.length(); i++)
              if (check.charAt(i) == vowel[i])
                  counter[i]++;
  
          for (int t : counter)
              total += t;
  
          System.out.println("Aantal klinkers: \t" + total);
  
      }
  }
  </code></pre>