I am completely new to Java and I am trying to get the user input to check my array for valid input and continue code and if it's not valid to repeat until I get valid input.
public class Cheesecake {
public static void main(String[] args) {
// TODO Auto-generated method stub
float biteSize = 3;
float small = 9;
float large = 12;
String chosenSize;
double pricePerInch = 0;
double total = 0;
String[] chooseSizes = {"bite size", "small", "large"};
String[] chooseFlavors = {"plain", "strawberry", "raspberry", "caramel", "chocolate"} ;
Scanner scnr = new Scanner(System.in);
System.out.println("Flavors to choose from: plain, strawberry, raspberry, caramel, chocolate."); //giving user flavor list
/*System.out.println("Please choose flavor:");
flavors = scnr.nextLine();*/
String flavors;
while (true) {
System.out.println("Please choose flavor:");
flavors = scnr.nextLine();
if (flavors.equals(chooseFlavors))
break;
else
System.out.println("Please choose from flavors above.");
{and}even on one lineifstatements. You will save yourself a lot of unnecessary hassle in the future.