Home > DeveloperSection > Forums > In Java, how can I test if an Array contains a certain value?
Royce Roy
Royce Roy

Total Post:134

Points:938
Posted on    April-09-2015 7:54 AM

 Java Java 
Ratings:


 1 Reply(s)
 709  View(s)
Rate this:

I have a String[] with values like so:

public static final String[] VALUES = new String[] {"AB","BC","CD","AE"};

Given String s, is there a good way of testing whether VALUES contains s?



Mayank Tripathi
Mayank Tripathi

Total Post:397

Points:3117
Supported
Posted on    April-09-2015 7:59 AM

Arrays.asList(yourArray).contains(yourValue)

Don't want to miss updates? Please click the below button!

Follow MindStick