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 list distinct by object attribute 
Java :: java does file exist 
Java :: how to solve Caused by: java.lang.IllegalStateException: You need to use a Theme.AppCompat theme (or descendant) with this activity. 
Java :: function in java 
Java :: java quotes in string 
Java :: getcurrencyinstance java example 
Java :: java method return list 
Java :: how to use deque as stack or queue in java? 
Java :: set ImageView size programmatically android 
Java :: how to find a word in string in java 
Java :: explicit casting 
Java :: break java 
Java :: java download image file 
Java :: java remove character from string after 
Java :: java date minus 1 day 
Java :: spring boot actuator 
Java :: java string regexp replace 
Java :: clone array in java 
Java :: java array loop 
Java :: retainall java 
Java :: how to remove null values collections 
Java :: java regex 
Java :: android:windowLightStatusBar programmatically 
Java :: matrice java 
Java :: change color of drawable android studio 
Java :: create array of particular length in java 
Java :: java binart tree print 
Java :: android sha1 key 
Java :: longest common subsequence of two strings 
Java :: Java How to use SortedSet? 
ADD CONTENT
Topic
Content
Source link
Name
5+8 =