need help!
import java.util.*;
public class Test {
protected String name;
protected String second;
protected String last;
protected void setFirstName(String name){
this.name=name;
}
protected void setSecondName(String a){
second=a;
}
protected void setLastName(String a){
last=a;
}
protected String getName(){
return name;
}
protected String getSecond(){
return second;
}
protected String getLast(){
return last;
}
public static void main(String[] args) {
Scanner scan = new Scanner(System.in);
Test[] a = new Test[3];
for(int i=0;i<3;i++){
System.out.println("Enter first name: ");
a.setFirstName(scan.nextLine());
System.out.println("Enter second name:");
a.setSecondName(scan.nextLine());
System.out.println("Enter last name");
a.setLastName(scan.nextLine());
}
for(int i=0;i<3;i++){
System.out.println(a.getName());
System.out.println(a.getSecond());
System.out.println(a.getLast());
}
}
}
Why, when I start the program and enter the first name to the console it throws a NullPointerException?

