I was curious how to check whether a value is in an array in Java
import java.util.Scanner;
Scanner keyboard = new Scanner(System.in);
String[] choices = {"choiceA", "choiceB", "choiceC"};
String userChoice = keyboard.nextLine();
Let's say we wanted to check if whatever value the user inputs into userChoice
is in the choices array
, how could I do that?