---
title: "In Java, how can I test if an Array contains a certain value?"  
description: "In Java, how can I test if an Array contains a certain value?"  
author: "Royce Roy"  
published: 2015-04-09  
updated: 2015-04-09  
canonical: https://www.mindstick.com/forum/23089/in-java-how-can-i-test-if-an-array-contains-a-certain-value  
category: "java"  
tags: ["java"]  
reading_time: 1 minute  

---

# In Java, how can I test if an Array contains a certain value?

I have a [String](https://www.mindstick.com/articles/1527/string-split-in-c-sharp)[] with [values](https://www.mindstick.com/forum/327/sum-textbox-values) like so:

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

Given String s, is there a good way of [testing](https://www.mindstick.com/articles/1849/role-of-testing-in-software-development) whether VALUES contains s?

## Replies

### Reply by Anonymous User

```
Arrays.asList(yourArray).contains(yourValue)
```


---

Original Source: https://www.mindstick.com/forum/23089/in-java-how-can-i-test-if-an-array-contains-a-certain-value

Copyright © MindStick Software Pvt. Ltd. This Markdown version is provided for developers, AI systems, and offline reading.
