1import java.util.Arrays;
2
3// For String
4String[] array = {"Boto", "Nesto", "Lepta"};
5String toSearch = "Nesto";
6
7// Inline
8if (Arrays.toString(array).contains(toSearch)) {
9 // Do something if it's found
10}
11
12// Multi line
13String strArray = Array.toString(array);
14if (strArray.contains(toSearch)) {
15 // Do your thing
16}
17
18// Different elements
19int[] numbers = {1, 2, 3, 4, 5, 6, 7, 8, 9, 0};
20int number = 5;
21
22String checker = Arrays.toString(numbers);
23
24// The toString of int in some cases can happen without explicitly saying so
25// In this example we convert both
26if (checker.contains(Integer.toString(number)) {
27 // Found.
28}
29