Skip to content

Commit

Permalink
Add findDuplicates
Browse files Browse the repository at this point in the history
  • Loading branch information
hemanth0525 committed Sep 1, 2024
1 parent 53f249d commit c455e6a
Showing 1 changed file with 2 additions and 4 deletions.
6 changes: 2 additions & 4 deletions src/main/java/org/apache/commons/collections4/ListUtils.java
Original file line number Diff line number Diff line change
Expand Up @@ -196,10 +196,8 @@ public static <E> List<E> findDuplicates(final List<E> list) {
List<E> result = new ArrayList<>();

for (E element : list) {
if (!seen.add(element)) {
if (duplicates.add(element)) {
result.add(element);
}
if (!seen.add(element) && duplicates.add(element)) {
result.add(element);
}
}

Expand Down

0 comments on commit c455e6a

Please sign in to comment.