How to check if exists any duplicate in Java 8 Streams?
Your code would need to iterate over all elements. If you want to make sure that there are no duplicates simple method like public static <T> boolean areAllUnique(List<T> list){ Set<T> set = new HashSet<>(); for (T t: list){ if (!set.add(t)) return false; } return true; } would be more efficient since it can give you … Read more