1package com.mkyong.core;
2
3import java.util.Arrays;
4import java.util.List;
5
6public class StringArrayExample1 {
7
8 public static void main(String[] args) {
9
10 String[] alphabet = new String[]{"A", "B", "C"};
11
12 // Convert String Array to List
13 List<String> list = Arrays.asList(alphabet);
14
15 if(list.contains("A")){
16 System.out.println("Hello A");
17 }
18
19 }
20
21}
22Copy
1 // Convert to stream and test it
2 boolean result = Arrays.stream(alphabet).anyMatch("A"::equals);
3 if (result) {
4 System.out.println("Hello A");
5 }
6Copy
1private static final Set<String> VALUES = Set.of(
2 "AB","BC","CD","AE"
3);
4