映射以获取子字符串并在Java中转换为int
假设以下是我们的信息流:
Stream.of("u2", "h9", "s8", "l3")现在,映射以获取子字符串:
.map(s -> s.substring(1))
转换为int并找到最小值:
.mapToInt(Integer::parseInt) .min()
以下是Map并获取子字符串并将其转换为int的示例:
示例
import java.util.stream.Stream;
public class Demo {
public static void main(String[] args) throws Exception {
Stream.of("u2", "h9", "s8", "l3")
.map(s -> s.substring(1))
.mapToInt(Integer::parseInt)
.min()
.ifPresent(System.out::println);
}
}输出结果
2
热门推荐
2 万寿祝福语简短
10 六十岁大寿祝福语简短
11 新生祝福语简短8字
12 冬至婆婆的祝福语简短
13 对离岗同事祝福语简短
14 奶奶生日感恩祝福语简短
15 送个姐妹生日祝福语简短
16 周年蛋糕祝福语简短英语
17 公司开年仪式祝福语简短
18 英语简短祝福语给学生