boolean eingabeIstInvalid;
do{
eingabeIstInvalid= false;
System.out.println("Wiederholen");
eingabe= scannerVariable.next().charAt(0);
switch (eingabe) {
case 'j':
final String os = System.getProperty("os.name");
if (os.contains("Windows")) {
try {
new ProcessBuilder("cmd", "/c", "cls").inheritIO().start().waitFor();
}
catch (IOException | InterruptedException ex) {
System.exit(0);
}
}
else {
System.out.print("\033[H\033[2J");
System.out.flush();
} // Löschvorgang
break;
case 'n':System.out.println("Beenden");
return;
default:eingabeIstInvalid= true;
} // end of switch
}while (eingabeIstInvalid);