이 프로그램에서 NullPointerException
이 발생합니다. Object Array를 선언 할 때 문제가 있다고 생각합니다.개체 배열 작업 중 NullPointerException
import java.util.Scanner;
class One
{
public static void main(String args[])
{
Scanner key = new Scanner(System.in);
two[] obj = new two[3];
for (int i = 0; i < 3; i++) {
obj[i].roll = key.nextInt();
obj[i].name = key.nextLine();
obj[i].grade = key.nextLine();
}
for (int i = 0; i < 3; i++) {
System.out.println(obj[i].roll + " " + obj[i].name + " " + obj[i].grade);
}
}
}
class Two
{
int roll;
String name, grade;
}
[Null Pointer Exception이란 무엇이며 어떻게 수정합니까?] (http://stackoverflow.com/questions/218384/what-is) -a-null-pointer-exception-and-how-do-i-fix-it) – Raedwald