Java Stream ??????
???????????? ???????[ 2016/3/11 13:20:45 ] ??????????????????? ???????
???????????????????????????????????????????????????????
????String[] arr = new String[]{"b_123"??"c+342"??"b#632"??"d_123"};List<String> l = Arrays.stream(arr) .sorted((s1??s2) -> { if (s1.charAt(0) == s2.charAt(0)) return s1.substring(2).compareTo(s2.substring(2)); else return s1.charAt(0) - s2.charAt(0); }) .collect(Collectors.toList());System.out.println(l); //[b_123?? b#632?? c+342?? d_123]
????skip
????skip??????????n????????????????е????С????????n????????????
?????????? terminal operations
????Match
????public boolean allMatch(Predicate<? super T> predicate)public boolean anyMatch(Predicate<? super T> predicate)public boolean noneMatch(Predicate<? super T> predicate)
????????鷽????????????е???????????????
????allMatch????????е??????????????????true??????flase???????????????true
????anyMatch???????????????????????????true??????flase??
????noneMatch????????е????????????????????true??????flase??
????System.out.println(Stream.of(1??2??3??4??5).allMatch( i -> i > 0)); //true System.out.println(Stream.of(1??2??3??4??5).anyMatch( i -> i > 0)); //true System.out.println(Stream.of(1??2??3??4??5).noneMatch( i -> i > 0)); //falseSystem.out.println(Stream.<Integer>empty().allMatch( i -> i > 0)); //true System.out.println(Stream.<Integer>empty().anyMatch( i -> i > 0)); //false System.out.println(Stream.<Integer>empty().noneMatch( i -> i > 0)); //true
????count
????count???????????е???????????????????
????mapToLong(e -> 1L).sum();
????collect
????<R??A> R collect(Collector<? super T??A??R> collector)<R> R collect(Supplier<R> supplier?? BiConsumer<R??? super T> accumulator?? BiConsumer<R??R> combiner)
??????????collector???mutable reduction???????????? Collectors ???????collector??????????????????????????????????μ?collector?????????????????????ù????????????????Щ??????????????????averagingInt????С?maxByminBy??????counting??????groupingBy???????????joining??????partitioningBy??????summarizingInt??????reducing?????toXXX???
??????????????????????????????????????α????
????R result = supplier.get();for (T element : this stream) accumulator.accept(result?? element);return result;
?????????
????List<String> asList = stringStream.collect(ArrayList::new?? ArrayList::add?? ArrayList::addAll);String concat = stringStream.collect(StringBuilder::new?? StringBuilder::append?? StringBuilder::append) .toString();
????find
????findAny()??????????????????????????????Optional????????????????????????????????????????????????????????findFirst()???????п???????е????????????????findFirst()???????????????????????????Optional??
????forEach??forEachOrdered
????forEach????????????????????????action???????????????????peek??????????????????????????????encounter order?????У??????????????????????encounter order?????У?????????forEachOrdered??????
????Stream.of(1??2??3??4??5).forEach(System.out::println);
??????С?
????max???????е?????min???????е?С???
????reduce
????reduce??????????????????????????????????????????м????????????
????pubic Optional<T> reduce(BinaryOperator<T> accumulator)pubic T reduce(T identity?? BinaryOperator<T> accumulator)pubic <U> U reduce(U identity?? BiFunction<U??? super T??U> accumulator?? BinaryOperator<U> combiner)
???????????????????е????????????????????????????????????????????
????Optional<Integer> total = Stream.of(1??2??3??4??5).reduce( (x?? y) -> x +y);Integer total2 = Stream.of(1??2??3??4??5).reduce(0?? (x?? y) -> x +y);
?????????????accumulator???????????(associative)??
????toArray()
?????????е???????????????С?
???????
????concat?????????????????????????
????public static <T> Stream<T> concat(Stream<? extends T> a?? Stream<? extends T> b)
????“
???????
????toArray???????????????????飬??????????????????????????????????collect??????????Collectors.toXXX?????????????
????public static <T??C extends Collection<T>> Collector<T?????C> toCollection(Supplier<C> collectionFactory)public static …… toConcurrentMap(……)public static <T> Collector<T?????List<T>> toList()public static …… toMap(……)public static <T> Collector<T?????Set<T>> toSet()
???????????
???????Stream?????????????????????Scala?????????????????Щ???Щ???????????????Щ?????????? protonpack ??????????з?????
????takeWhile and takeUntil
????skipWhile and skipUntil
????zip and zipWithIndex
????unfold
????MapStream
????aggregate
????Streamable
????unique collector
????java8-utils ??????Щ??????????????
???????????????????????漰???????????????????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 ??????