IN JAVA, HOW CAN I TEST IF AN ARRAY CONTAINS A CERTAIN VALUE?

ben reitman

Total Post:96

Points:676
Posted by  ben reitman
Java  Array 
 743  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. Mayank Tripathi

    Post:397

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

    Arrays.asList(yourArray).contains(yourValue)

  1. wushiwu08 wushiwu08

    Post:3

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

    Post is removed by the Admin.

Answer

NEWSLETTER

Enter your email address here always to be updated. We promise not to spam!