Search
 
SCRIPT & CODE EXAMPLE
 

JAVA

java 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

PREVIOUS NEXT
Code Example
Java :: java stream distinct by object atribute 
Java :: caused by: java.lang.noclassdeffounderror: org/springframework/boot/configurationprocessor/json/jsonexception 
Java :: lambda comparator java 
Java :: keytool error: java.io.FileNotFoundException: my-release-key.keystore (Access is denied) java.io.FileNotFoundException: my-release-key.keystore (Access is denied) 
Java :: double quotes in string java 
Java :: materialbutton remove shadow xml 
Java :: return the maximum sum of two numbers whose digits add up to an equal sum 
Java :: android add activity parent manifest 
Java :: final method meaning 
Java :: root to leaf sum leetcode 
Java :: How to generate all possible IP addresses based on a given set of digits, in Java? 
Java :: print an array java 
Java :: dark mode app android studio 
Java :: java create file in folder 
Java :: Java Create a ConcurrentHashMap 
Java :: Printing array list through for loop in java 
Java :: ternary operator in java for null check 
Java :: java sleep 1 second 
Java :: print list of map java 
Java :: Send image file to server useing Retrofit 
Java :: java enums 
Java :: android @Parcelize not resolving 
Java :: integer.tostring java 
Java :: icon label java 
Java :: param query spring boot 
Java :: declare class constant array java 
Java :: glide dependency 
Java :: java 8 find in list 
Java :: heap in java 
Java :: java fahrenheit to celsius 
ADD CONTENT
Topic
Content
Source link
Name
7+2 =