package com.br.arch.geo.pulsar.admin.jkd8;
import java.util.ArrayList;
import java.util.List;
import java.util.stream.Collectors;
public class JDK8Filter {
public static void main(String[] args) {
List<String> testFilterList = new ArrayList<String>();
testFilterList.add("test");
testFilterList.add("yinzhen");
testFilterList.add("aatestbb");
System.out.println("-------------过滤前-------------");
for(String tempStr :testFilterList) {
System.out.println(tempStr);
}
//过滤包含test的集合
testFilterList = testFilterList.stream().filter(tempStr-> tempStr.contains("test")).collect(Collectors.toList());
System.out.println("-------------过滤后-------------");
for(String tempStr :testFilterList) {
System.out.println(tempStr);
}
/**
* -------------过滤前-------------
test
yinzhen
aatestbb
-------------过滤后-------------
test
aatestbb
*/
}
}
【JDK】【10】jdk1.8 filter过滤
最新推荐文章于 2023-11-29 18:00:00 发布