ユーザーに 10 個の名前を入力し、名前をアルファベット順に並べ替え、それぞれの名前、文字数、母音の数を出力するプログラムを作成する必要があります。私は近いと思いますが、処理中にこのエラーが発生し続けます。誰でもこれを手伝ってもらえますか?
`Exception in thread "Animation Thread" java.lang.NullPointerException
at java.lang.String$CaseInsensitiveComparator.compare(String.java:1217)
at java.lang.String$CaseInsensitiveComparator.compare(String.java:1211)
at java.lang.String.compareToIgnoreCase(String.java:1258)
at test.setup(test.java:35)
at processing.core.PApplet.handleDraw(PApplet.java:2117)
at processing.core.PGraphicsJava2D.requestDraw(PGraphicsJava2D.java:193)
at processing.core.PApplet.run(PApplet.java:2020)
at java.lang.Thread.run(Thread.java:662)`
私のコードは次のとおりです。
import javax.swing.*;
String names[] = new String[10];
String temp;
String nameInput;
int length;
int vowel = 0;
char ch;
length = 0;
// store user input to array
for (int i = 0; i < names.length; i++) {
  nameInput = JOptionPane.showInputDialog ("Enter a name:");
  names[i] = nameInput;
  length = names[i].length();
// sort into alphabetical order
  for (int j = 0; j < names.length - 1; j++) {
    for (int k = j + 1; k < names.length; k++) {
      if (names[j].compareToIgnoreCase(names[k]) > 0) {
        temp = names[j];
        names[j] = names[k];
        names[k] = temp;
      }
    }
  }
  // count vowels
  char[] characters = nameInput.toCharArray();
  for (int m = 0; m < characters.length; m++) {
    ch = nameInput.charAt(m);
    if ((ch == 'A') || (ch == 'a')
      ||  (ch == 'E') || (ch == 'e')
      ||  (ch == 'I') || (ch == 'i')
      ||  (ch == 'O') || (ch == 'o')
      ||  (ch == 'U') || (ch == 'u')) {
      vowel++;
    }
  }
  System.out.println("Name: " + names[i] + ", Length: " + length + ", Vowels: " + vowel);
  vowel = 0;
}