반응형

배열에서의 특정 값 유무 확인 방법
1. Stream 사용
boolean contains = Arrays.stream(arr).anyMatch(String::equals);

2. Set 사용
- java9 이상 : Set.of().contains()
- java9 미만 : new HashSet<>(Arrays.asList(arr))

2021-11-06
3. ImmutableSet
ImmutableSet.of().contains()
반응형