Tag Archives: dup

[java] 문자열 리스트(List) 중복(dup, duplicate) 체크(check)

By | 7월 5, 2021

/** * 매개변수로 받은 문자열 list에 중복이 존재할 경우 true, 아니면 false 리턴 * * @param list * @return */ public static boolean hasDuplicated(List<String> list) { if(list == null){ return false; } Set<String> set = new HashSet<>(list); if(set.size() < list.size()){ return true; } return false; } 참고 https://stackoverflow.com/questions/562894/java-detect-duplicates-in-arraylist