I have multiple Scanner methods to save input, but when I execute the code and enter for example "word 5", the Scanner reads input for the next Scanner method as well. How can I stop that?
...
correctInput = true;
for (int i = 0; i < runnI; i++) {
System.out.println(".....");
array1[i] = sc.next();
System.out.println(".....");
do {
try {
array2[i] = sc.nextDouble();
correctInput= false;
} catch (InputMismatchException e) {
System.out.println("Wrong");
sc.next();
}
} while (correctInput);
}