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

Total Post:96

Points:676
Posted on    May-08-2015 1:08 AM

 Java Java  Array 
Ratings:


 2 Reply(s)
 450  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
Posted on    May-08-2015 6:28 AM

Arrays.asList(yourArray).contains(yourValue)

wushiwu08 wushiwu08
wushiwu08 wushiwu08

Total Post:3

Points:21
Posted on    May-09-2015 12:33 AM

Post is removed by the Admin.

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

Follow MindStick