New to the forum. Tried searching but could not find anything that helped. I ran this code on another IDE with java 1.7 without issue. I am now using Eclipse and updated java to 1.8 and am getting the error: java.util.NoSuchElementException regarding line "response = input.nextLine();". Strange thing is that I have another function that returns a string and is coded with the exact same loop (do/while with a pattern check) and it seems to be working fine.
static boolean search_again() {
String response;
//Scanner input = new Scanner(System.in);
do {
System.out.println("Would you like to search another site? ");
Scanner input = new Scanner(System.in);
response = input.nextLine();
input.reset();
}
while(!response.toUpperCase().matches("Y|YE|YES") && !response.toUpperCase().matches("N|NO"));
if (response.matches("[nN[oO]?]")) {
System.out.println("Goodbye");
return false;
}
else {
System.out.println("OK - search again!");
return true;
}
}