import java.util.*;
import java.util.stream.*;
public class DuplicateNumber {
public static void main(String a[])
{
List<Integer> list = Arrays.asList(1, 1, 3, 4, 5, 6, 8, 8, 10, 10);
List<Integer> result = list.stream()
.collect(Collectors.groupingBy(i ->i,Collectors.counting()))
.entrySet()
.stream()
.filter( e -> e.getValue() >0)
.map(Map.Entry::getKey)
.collect(Collectors.toList());
System.out.println("---- Value of -----"+result);
}
}
No comments:
Post a Comment