Однако, несмотря на все мои усилия, я Мне не удалось достичь желаемого результата. Буду очень признателен за любую помощь в решении данного вопроса. Вот соответствующая часть моего кода:
Код: Выделить всё
System.out.println("\nEnter name: ");
String name = in.nextLine();
int length = name.length();
for (int x = 0; x < length; x++) {
if(name.substring(x, x + 1).equals(".")) {
System.out.println("Error! - name cannot contain (.) values\n"
+ "***************************************************");
System.out.println("\nWould you like to capture another name?" +
"\nEnter (1) to continue or any other key to exit");
String opt1 = in.nextLine();
// If statement to restart the application
if (opt1.equals("1")) {
System.out.println("menu launch");
} else {
System.exit(0);
}
} else {
break;
}
}
Подробнее здесь: https://stackoverflow.com/questions/692 ... variable-i