I'm currently trying to accept input into two arrays simultaneously. The reason being that the data at each position of the array is corresponding, eg. Name and ID number.
String[] arr = new String[5];
int[] arr1 = new int[5];
Scanner kb = new Scanner(System.in);
for(int i = 0; i<5; i++)
{
System.out.println("Enter a name:");
arr[i] = kb.nextLine();
System.out.println("Enter an ID:");
arr1[i] = kb.nextInt();
}
I have this code so far, but whenever i run it, it asks for a name and ID once then asks for both but only will accept ID.
I cant seem to figure out why it doesnt allow the name to be inputted, it just returns an incompatible data type error for that.