Snippets tagged “java-8”
2 snippets use this tag.
- Java 8 Distinct by propertyJava
To get a list of distinct elements by a property in Java 8, you can use the distinct() method of the Stream interface and the map() method to extract the property from each element.
- Java 8 List<V> into Map<K>Java
To convert a List<V> into a Map<K> in Java 8, you can use the toMap() method of the Collectors class from the java.util.stream package.