java array contains value example
Example 1: Check if an array contains an element java
import java.util.Arrays;
String[] array = {"Boto", "Nesto", "Lepta"};
String toSearch = "Nesto";
if (Arrays.toString(array).contains(toSearch)) {
}
String strArray = Array.toString(array);
if (strArray.contains(toSearch)) {
}
int[] numbers = {1, 2, 3, 4, 5, 6, 7, 8, 9, 0};
int number = 5;
String checker = Arrays.toString(numbers);
if (checker.contains(Integer.toString(number)) {
}
Example 2: java array contains
Arrays.asList(yourArray).contains(yourValue)