0
0

More than 1 year has passed since last update.

Stream#max()

Posted at

max,minは、Comparatorを渡す

public class Outer {
    public static void main(String[] args) {
        List<String> l = List.of("C","X","A");
        l.stream().max((a,b) -> a.compareTo(b)).ifPresent(System.out::println);
        l.stream().min((a,b) -> a.compareTo(b)).ifPresent(System.out::println);
    }
}
X
A
0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0