i don’t why i’m getting this exception !
my method is very simple it will loop to fill my parallel arrays
here is my method
public void fillPhoneBook(){
Scanner in = new Scanner(System.in);
for(int i=0;i<this.names.length;i++){
System.out.println("Enter Name:");
this.names[i] =in.next();
System.out.println("Enter Phone Number:");
this.telephones[i]=in.next();//here start rising exception
}
in.close();
i get this exception after the second input !`
— UPDATE —
sorry the problem was with initializing the telephones array
I have created the same scenario as you explained but the strange thing is that I am not getting any such exception. Please have a look at the code below
Output