Skip to content

Instantly share code, notes, and snippets.

@gabhi
Created April 5, 2014 07:18
Show Gist options
  • Save gabhi/9988481 to your computer and use it in GitHub Desktop.
Save gabhi/9988481 to your computer and use it in GitHub Desktop.
In Java, how can I test if an Array contains a certain value?
String[] VALUES = new String[] {"AB","BC","CD","AE"};
String value= "AB";
String notExists = "abc";
Arrays.asList(VALUES).contains(value); //TRUE
Arrays.asList(VALUES).contains(notExists); //FALSE
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment