0
문자열 배열 색인을 구문 분석하려고 할 때 널 포인터 예외가 발생합니다. 이 문제를 어떻게 해결할 수 있습니까? 감사합니다배열을 구문 분석하려고 할 때 널 포인터 예외가 발생합니다.
public class studentclass {
public static void main(String[] args){
Scanner scan = new Scanner(System.in);
String[][] student = new String[10][];
Double[][] results = new Double[10][];
Double[] total = new Double[10];
String tableln = "";
for(int index = 0; index < student.length; index++){
System.out.println("\nPlease enter student " + (index+1) + "'s details");
String userinput = scan.nextLine();
student[index] = userinput.split(",");
//converts string array in to double array but receiving null pointer exception
results[index][0] = Double.parseDouble(student[index][2]);
results[index][1] = Double.parseDouble(student[index][3]);
results[index][2] = Double.parseDouble(student[index][4]);
results[index][3] = Double.parseDouble(student[index][5]);
total[index] = (results[index][0]*0.1+results[index][1]*0.4+
results[index][2]*0.3+results[index][3]*0.2);
예는 다음과 같습니다 당신은 항상 네 개의 값을 저장하는 경우처럼
, 무언가를 추가 할 수 있습니다. 죄송합니다. 잊어 버렸습니다. – Michael
결과 [색인]을 (를) 초기화해야합니다. – mikebabcock