たとえば、ユーザーは「1 2 3 4」と入力します。これらの4つの数字を抽出して、配列の別々の場所に挿入するにはどうすればよいですか?各数字をスペースで区切って文字列の数字セットとしてユーザーが入力する各数字を取得するにはどうすればよいですか?
私はちょっと初心者なので、私の知識が不足していると言い訳してください。
for (int i = 0; i < students; i++) {
scanner.nextLine();
tempScores[i] = scanner.nextLine();
tempScores[i] = tempScores[i] + " ";
tempNum = "";
int scoreCount = 0;
for (int a = 0; a < tempScores[i].length(); a++) {
System.out.println("Scorecount " + scoreCount + " a " + a);
if (tempScores[i].charAt(a) != ' ') {
tempNum = tempNum + tempScores[i].charAt(a);
} else if (tempScores[i].charAt(a) == ' ') {
scores[scoreCount] = Integer.valueOf(tempNum);
tempNum = "";
scoreCount ++;
}
}
['split(" ")'](https://docs.oracle.com/javase/7/docs/api/java/lang/String.html#split%28java.lang.String%29) – Andreas