In this case, if the user enters any one of the values available in the array fruits
, I want the if
statement to come true
, however I don't understand how to accomplish that.
import java.util.Scanner;
public class Strings {
public static void main(String[] args) {
Scanner Scan = new Scanner(System.in);
String[] fruits = {"Apple", "apple", "Banana", "banana", "Orange", "orange"};
System.out.println("Enter a name of a fruit: ");
String input = Scan.nextLine();
if(/*input = any one of the values in Array fruits*/){
System.out.println("Yes, that's a fruit");
}
else{
System.out.println("No, that's not a fruit.");
}