I need to do some data validation to ensure that the user enters one of the 4 these 4 choices (small,medium, large, super size) I never did data validation with Strings, must be there another way for this to work?
public static String orderSize()
{
System.out.println("What size - small, medium, large, or super size?");
String sizeChoice=input.nextLine();
while (sizeChoice != "small" + "medium" + "large" + "super");
{
System.out.println("Must be one of the sizes listed above here.");
System.out.println("What size - small, medium, large, or super size?");
sizeChoice=input.nextLine();
}
return sizeChoice;
while (sizeChoice != "smallmediumlargesuper"). Also, get rid of the semicolon at the end of thatwhileline - it terminates the statement - which IS thewhile, which means the block in the braces is not in the while loop at all !