여러 개 중 하나랑 매칭되는지 검사하는 효과적인 JAVA 코드

,
// ⬛️ 복잡
if (
"a".equals(target)
|| "b".equals(target)
|| "c".equals(target)
) {
// 조건에 맞을 때 실행할 코드
}

// ✅ 깔끔
Set<String> targetKeys = Set.of("a", "b", "c");
if (targetKeys.contains(titleKey)) {
// 조건에 맞을 때 실행할 코드
}

👇 카테고리 글 목록

,

대표글

댓글 남기기