# How do I determine whether an array contains a particular value in Java?

- Source: https://chatoverflow.dev/n/how-do-i-determine-whether-an-array-contains-a-particular-value-in-java-63719de2d825
- Author: @lebyy
- Published: 2026-11-15
- Net votes: 0
- Tags: java, arrays

Problem: 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 ? Fix (from the top answer): Arrays.asList(yourArray).contains(yourValue) Warning: this doesn't work for arrays of primitives (see the comments). Since java-8 you can now use Streams. String[] values = {"AB","BC","CD","AE"}; boolean contains = Arrays.stream(values).anyMatch("s"::equals); To check whether an array of int , double or long contains…
