Java Stream API?????
?????CarpenterLee ???????[ 2017/3/15 13:36:33 ] ??????????????????? Java
???????collect()????Map
????????????? Stream ??????????????????????????????????顢??????????????? Map ?????????? Stream ???? Map ??????????????????? Map ?? key ?? value ?????????????????????????????????????????????????? collect() ???????? Map ??
??????? Collectors.toMap() ???????????????????????????? Map ?? key ?? value ??
??????? Collectors.partitioningBy() ???????????????????ж???????????????
??????? Collectors.groupingBy() ??????????????????? group ??????????
???????1????? toMap() ?????????????????????????????????????????????? Collectors.toCollection() ???е?????????′???????????б???????? <??? gpa=""> ???? Map ?????????????????
????// ???toMap()??????GPA
????Map<Student?? Double> studentToGPA =
????students.stream().collect(Collectors.toMap(Functions.identity()??// ???????key
????student -> computeGPA(student)));// ???????value
???????2????? partitioningBy() ?????????????????????????? Stream ?е?????????????????????????????????????????????????????????????????????????????д????????????????????????????????
????// Partition students into passing and failing
????Map<Boolean?? List<Student>> passingFailing = students.stream()
????.collect(Collectors.partitioningBy(s -> s.getGrade() >= PASS_THRESHOLD));
???????3????? groupingBy() ????????????????????????????????SQL?е? group by ????????????? groupingBy() ????????????????????з??飬?????????????????? Map ?????? key ??????д???????????????????з??飺
????// Group employees by department
????Map<Department?? List<Employee>> byDept = employees.stream()
????.collect(Collectors.groupingBy(Employee::getDepartment));
???????????????????÷?????Щ????????????????????SQL????? group by ?????Э??????????????? 1. ???????????????飬2. ?????????????????????? ??Java??????????????????????????????? groupingBy() ????????????????????? groupingBy() ??????????????????????????????????????????????????????????????????????????????????? ????????? ?????????????????????????? ????????? ( downstream Collector )??
????// ???????????????????????????
????Map<Department?? Integer> totalByDept = employees.stream()
????.collect(Collectors.groupingBy(Employee::getDepartment??
????Collectors.counting()));// ?????????
??????????????????????????SQL??????????????и????????????????????????????ε?????????????????????????????????????????????????????????????????????????? ????????????????????????????????????????? Employee ???? ??????????·????????
????// ???????????????飬????????????????
????Map<Department?? List<String>> byDept = employees.stream()
????.collect(Collectors.groupingBy(Employee::getDepartment??
????Collectors.mapping(Employee::getName??// ?????????
????Collectors.toList())));// ?????ε??????
???????????????????ж?Java???????????????????????????????Java?????????????
???????collect()???????join
?????????????????????????????????????? Collectors.joining() ????????????????? for ????? Collectors.joining() ????????????д?????????????????????????????????????????????
????// ???Collectors.joining()????????
????Stream<String> stream = Stream.of("I"?? "love"?? "you");
????//String joined = stream.collect(Collectors.joining());// "Iloveyou"
????//String joined = stream.collect(Collectors.joining("??"));// "I??love??you"
????String joined = stream.collect(Collectors.joining("??"?? "{"?? "}"));// "{I??love??you}"
????collect()????????????
?????????????? Collectors ????????????????????????????????????????????????????? collect(Supplier<R> supplier?? BiConsumer<R??? super T> accumulator?? BiConsumer<R??R> combiner) ?????? ????κ?????????????? ?????? Collectors ??????????????????????????????????????????????????
???????????????????????漰???????????????????SPASVOС??(021-61079698-8054)?????????????????????????
??????
Java???????????Щ???????????????Java????????????????Java?б???Map????????Java Web???????????????Java??????????????д?????Java????????7???????????????????????(java .net ?????)???Java??????????Python??????Java webdriver??λ????????′????е?????Java??д??????????????????Java???????????????JavaScript????????????Java?????????????????? Java???????10??????????????Java?м????????????????java???????ü???????????м???????????????????
???·???
??????????????????
2023/3/23 14:23:39???д?ò??????????
2023/3/22 16:17:39????????????????????Щ??
2022/6/14 16:14:27??????????????????????????
2021/10/18 15:37:44???????????????
2021/9/17 15:19:29???·???????·
2021/9/14 15:42:25?????????????
2021/5/28 17:25:47??????APP??????????
2021/5/8 17:01:11????????
?????????App Bug???????????????????????Jmeter?????????QC??????APP????????????????app?????е????????jenkins+testng+ant+webdriver??????????????JMeter????HTTP???????Selenium 2.0 WebDriver ??????