Search
 
SCRIPT & CODE EXAMPLE
 

JAVA

java get distinct values from list

List<String> distinctElements = list.stream()
                        .distinct()
                        .collect(Collectors.toList());
Comment

java list distinct by key

public static <T> Predicate<T> distinctByKey(Function<? super T, ?> keyExtractor) {
    Set<Object> seen = ConcurrentHashMap.newKeySet();
    return t -> seen.add(keyExtractor.apply(t));
}

persons.stream().filter(distinctByKey(Person::getName))
Comment

get distinct values from list of objects java

public Set<String> areas(final List<Employee> employees) {
    Set<String> areas = new HashSet<>();
    for(final Employee employee: employees) {
        areas.add(employee.getArea());
    }
    return areas;
}
Comment

PREVIOUS NEXT
Code Example
Java :: java button 
Java :: Lunar New Year 
Java :: input date in java 
Java :: jackson object to string 
Java :: how to get length of integer in java 
Java :: how to pass enum in postman body 
Java :: input java 
Java :: how to import java.util 
Java :: hashtable contains key java 
Java :: sreekanth kasani 
Java :: how to add to arras java 
Java :: find duplicate value in array using java 
Java :: how to make a char uppercase in java 
Java :: set scrollbar transparent jscrollpane 
Java :: how to move from one activity to another in android studio on button click 
Java :: java.lang.ExceptionInInitializerError: null 
Java :: isblank vs isempty 
Java :: how to check if a string is empty or null in Android Studio 
Java :: char equals java 
Java :: java random a-z 
Java :: check character is alphanumeric java 
Java :: android kotlin center text 
Java :: what is the use of println 
Java :: object to double java 
Java :: java try catch 
Java :: android push notification icon 
Java :: android use attribute color programmatically 
Java :: how to resize image in android programmatically 
Java :: jframe visible 
Java :: comment in java 
ADD CONTENT
Topic
Content
Source link
Name
2+4 =