Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR JAVA

java stream get all max values

int longest = list.stream()
                  .mapToInt(String::length)
                  .max()
                  .orElse(-1);

List<String> result = list.stream()
                          .filter(s -> s.length() == longest)
                          .collect(toList());
Source by stackoverflow.com #
 
PREVIOUS NEXT
Tagged: #java #stream #max #values
ADD COMMENT
Topic
Name
3+2 =