Java Lambda
Lambda
<http://naotu.baidu.com/file/6f48a8bf61f964bd63b986bdb83c2e79?token=11d0ce93b785bbf2>
示例
单词转大写1
2
3
4String sentence = "Start Using Java Lambda Expressions";
List<String> words = Arrays.stream(sentence.split(" "))
.map(String::toUpperCase)
.collect(toList());
获取字符串的单词长度和1
2
3
4
5String sentence = "Start Using Java Lambda Expressions";
int length = Arrays.stream(sentence.split(" "))
.map(String::length)
.reduce(0, Integer::sum)
.intValue();;
奇偶数分组1
Map<Boolean, List<Integer>> res = Arrays.asList(1, 2, 3, 4, 5, 6).stream().collect(partitioningBy(i -> (i % 2 == 0)));
1 | Object[] args = ...; |
本站采用「署名 4.0 国际」进行许可。