I'm trying to prompt the user to type in a string, which will be stored in an array of strings, followed by an inputted int which will be placed into an int array.
I'm running into a problem where the first line is printed, but the user isn't prompted to type in a string. Then the second print statement is immediately printed, and the user is only able to type in an int.
So far I have:
int i, n = 10;
String[] sentence = new String[1000];
int[] numbers = new int[1000];
for(i = 0; i < n; i++)
{
System.out.println("Enter String" + (i + 1) + ":");
sentence[i] = scan.nextLine();
System.out.printf("Enter int " + (i + 1) + ":");
numbers[i] = scan.nextInt();
}
As output I get:
Enter String 1:
Enter int 1:
Here you can input an int, and it is stored into the int array. But you can't input a String for the String array.
Ples help.