Kubernate

Java 8 # Remove Duplicate Number from Array.

 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

Spring Boot - Bean LifeCycle

 Here is a clear, step-by-step lifecycle of a Spring Boot application , explained in a simple + interview-ready way. 🔄 Spring Boot Applica...

Kubernate