In Java, how can I test if an Array contains a certain value?

Total Post:149

Points:1043
Java 
 1522  View(s)
Ratings:
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?

  1. Post:397

    Points:3117
    Re: In Java, how can I test if an Array contains a certain value?

    Arrays.asList(yourArray).contains(yourValue)

Answer

Please check, If you want to make this post sponsored

You are not a Sponsored Member. Click Here to Subscribe the Membership.