Compiler issues: NullPointerException in the line "mass[i].mainN = scan.nextInt();". To my mind, I've inizialized all variables "mainN" and the array "mass". What can be the reason of the exception?
import java.util.Scanner;
public class Robotics{
public static void main(String[] args) {
Scanner scan = new Scanner(System.in);
int N = scan.nextInt();
Robo[] mass = new Robo[N];
for(int i = 0; i < mass.length; i++) {
mass[i].mainN = scan.nextInt();
mass[i].auxiliary = scan.nextInt();
}
scan.close();
}
class Robo{
int mainN;
int auxiliary;
}