title: exception in the given code(java)
body: <p>I have this test program where I am seeing a NullPointer exception. I need help finding out how to solve it and would like to know the root cause.</p>
  
  <pre><code>public class test {
  
      private static void practice(String[] words) {
  
          int vowelPosition = 0;
          int consonantPosition = 0;
          char[] vowel = (char[]) null;
          char[] consonant = (char[]) null;
  
          for (int i = 0; i &lt; words.length; i++) {
              int currentWordLength = words[i].length();
              for (int j = 0; j &lt; currentWordLength; j++) {
                  if (words[i].charAt(j) == 'a' || words[i].charAt(j) == 'e'
                          || words[i].charAt(j) == 'i'
                          || words[i].charAt(j) == 'o'
                          || words[i].charAt(j) == 'u') {
                      consonant[j] = 'n';
                      vowel[j] = words[i].charAt(j);
  
                      vowelPosition = j;
                      System.out.println(j + "At this position is "
                              + vowel[vowelPosition]);
                  } else {
                      vowel[j] = 'n';
                      consonant[j] = words[i].charAt(j);
                      consonantPosition = j;
                      System.out.println(j + " At this position is "
                              + consonant[consonantPosition]);
                  }
  
              }
          }
  
      }
  
      public static void main(String[] args) {
          // TODO Auto-generated method stub
          String[] words = { "harpreet" };
          practice(words);
      }
  
  }
  </code></pre>
  
  <p>I also tried debugging it and found the inner loop is throwing the exception.</p>