Hi guys, I'm new to Java and was wondering if you could help with one little problem with my code.
System.out.print("Enter title: ");
String title = keyboard.next();
if (title.equals("Mrs") || title.equals("Miss") || title.equals("Mr") || title.equals("Ms"))
{
title = title;
}
else
{
System.out.println("Enter a valid title");
}
If the title entered is different from the acceptable values, the error message pops up. How can I add a method (after System.out.println) which does not allow you to go any further until a valid value is entered, because at the moment even if I enter an invalid value the message appears but the title is set to that invalid value. I'm testing this using a TextUI.
Thanks in advance