I have an if statement that checks so that someone has entered an input correct and not only whitespace or blank. I also want it to allow for the swedish letters å, ä and ö and not only the letters a - z. I cannot find how to get it right. I appreciate your help!
String name;
do {
System.out.print("name: ");
name = scanner.nextLine();
if (!name.matches("[A-Za-z]+")) {
System.out.println("Wrong input, try again!");
}
} while
Aucun commentaire:
Enregistrer un commentaire