We would like to know how to map to get substring and convert to int then get max value.
//w w w. j av a2s.com import java.util.stream.Stream; public class Main { public static void main(String[] args) throws Exception { Stream.of("a1", "a2", "a3") .map(s -> s.substring(1)) .mapToInt(Integer::parseInt) .max() .ifPresent(System.out::println); } }
The code above generates the following result.