Rather than calling the Arrays class, you could just iterate through the array yourself
String[] array = {"x", "y", "z"}; String myVar = "x"; for(String letter : array) { if(letter.equals(myVar) { System.out.println(myVar +" is in the list"); } }
Remember that a String is nothing more than a character array in Java. That is
String word = "dog";
is actually stored as
char[] word = {"d", "o", "g"};
So if you would call if(letter == myVar), it would never return true, because it is just looking at the reference id inside the JVM. That is why in the code above I used
if(letter.equals(myVar)) { }