I have a String[]
with values like so:
public static final String[] VALUES = new String[] {\"AB\",\"BC\",\"CD\",\"AE\"};
Given
With Java 8 you can create a stream and check if any entries in the stream matches "s"
:
String[] values = {"AB","BC","CD","AE"};
boolean sInArray = Arrays.stream(values).anyMatch("s"::equals);
Or as a generic method:
public static boolean arrayContains(T[] array, T value) {
return Arrays.stream(array).anyMatch(value::equals);
}