How do I get user input while asking the user Do you want to continue or not?
If the user press开发者_运维百科 Enter then how do I go to the next instructions so I compare it to do other tasks?
Scanner scanner = new Scanner(System.in);
scanner.nextLine();
Edit: Sorry, misread question (well question title and body is different). You can ask the user like this:
System.out.print("Do you want to continue? ");
Scanner scanner = new Scanner(System.in);
if (scanner.next().toLowerCase().equals("y")) {
// continue...
} else {
// don't continue
}
So when a user types in "y" or "Y" it will continue. Otherwise, it won't.
精彩评论