ITeye博客

jvisualvm

fairy_xzc · 共 511 篇文章

CompletableFuture - 常用API( 下)

原创转载请注明出处: http://agilestyle.iteye.com/blog/2427515 runAfterBoth private static void testRunAfterBoth() { CompletableFuture.supplyAsync(() -> { System.out.println(Thread.currentThread().getName() + " is running"); return 1; }).runAfterBoth(CompletableFuture.supplyAsync(() -> { System.out.println(Th…

2018-07-25 22:03 · Concurrent · 评论(0)

CompletableFuture - 常用API(上)

原创转载请注明出处: http://agilestyle.iteye.com/blog/2427512 先看一个简单的例子 package org.fool.java8.completable; import java.util.Arrays; import java.util.List; import java.util.Random; import java.util.concurrent.CompletableFuture; import java.util.concurrent.ExecutionException; import java.util.concurrent.Execu…

2018-07-25 21:21 · Concurrent · 评论(0)

CompletableFuture - Hello World

原创转载请注明出处: http://agilestyle.iteye.com/blog/2427053 completableFuture.get() package org.fool.java8.completable; import java.util.Optional; import java.util.Random; import java.util.concurrent.CompletableFuture; import java.util.concurrent.ExecutionException; public class CompletableFutureTest0 { pr…

2018-07-17 23:27 · Concurrent · 评论(0)

Collectors - The Collector interface

原创转载请注明出处: http://agilestyle.iteye.com/blog/2425967 The Collector Interface public interface Collector<T, A, R> { Supplier<A> supplier(); BiConsumer<A, T> accumulator(); BinaryOperator<A> combiner(); Function<A, R> finisher(); Set<Collector.Characteristics> characteristics(); } Note: T is the gener…

2018-07-01 22:53 · FP · 评论(0)

Collectors - Demo4

原创转载请注明出处: http://agilestyle.iteye.com/blog/2425966 Outline testSummingDouble(); testSummingLong(); testSummingInt(); testToCollection(); testToConcurrentMap(); testToConcurrentMapWithBinaryOperator(); testToConcurrentMapWithBinaryOperatorAndSupplier(); testToList(); testToSet(); testToMap(); testT…

2018-07-01 22:40 · FP · 评论(0)

Collectors - Demo3

原创转载请注明出处: http://agilestyle.iteye.com/blog/2425965 Outline testPartitioningByWithPredicate(); testPartitionByWithPredicateAndCollector(); testReducingBinaryOperator(); testReducingBinaryOperatorAndIdentity(); testReducingBinaryOperatorAndIdentityAndFunction(); testSummarizingInt(); testSummarizing…

2018-07-01 22:32 · FP · 评论(0)

Collectors - Demo2

原创转载请注明出处: http://agilestyle.iteye.com/blog/2425963 Outline testAveragingDouble(); testAveragingInt(); testAveragingLong(); testCollectingAndThen1(); testCollectingAndThen2(); testCounting(); testGroupingByFunction1(); testGroupingByFunction2(); testGroupingByFunction3(); testSummarizingInt(); SRC …

2018-07-01 22:32 · FP · 评论(0)

Collectors - Demo1

原创转载请注明出处: http://agilestyle.iteye.com/blog/2425964 Outline testGroupingByConcurrent(); testGroupingByConcurrentWithFunctionAndCollector(); testGroupingByConcurrentWithFunctionAndSupplierAndCollector(); testJoining(); testJoiningWithDelimiter(); testJoiningWithDelimiterAndPrefixAndSuffix(); testMap…

2018-07-01 22:26 · FP · 评论(0)

Stream - Reduce

原创转载请注明出处: http://agilestyle.iteye.com/blog/2425206 reduce sum private static void reduceSumTest1() { Stream<Integer> stream = Arrays.stream(new Integer[]{1, 2, 3, 4, 5, 6, 7}); Integer reduce = stream.reduce(0, (i, j) -> i + j); System.out.println(reduce); } private static void reduceSumTest2() { …

2018-06-19 22:21 · FP · 评论(0)

Stream - Match

原创转载请注明出处: http://agilestyle.iteye.com/blog/2425204 allMatch private static void allMatch() { Stream<Integer> stream = Arrays.stream(new Integer[]{1, 2, 3, 4, 5, 6, 7}); boolean result = stream.allMatch(i -> i > 0); System.out.println(result); } anyMatch private static void anyMatch() { Stream<Inte…

2018-06-19 21:52 · FP · 评论(0)

Stream - Find

原创转载请注明出处: http://agilestyle.iteye.com/blog/2425205 optional.get private static void optionalGetTest() { Stream<Integer> stream = Arrays.stream(new Integer[]{1, 2, 3, 4, 5, 6, 7}); Optional<Integer> optional = stream.filter(i -> i % 2 == 0).findAny(); System.out.println(optional.get()); } Console O…

2018-06-19 21:51 · FP · 评论(0)

Stream - Map

原创转载请注明出处: http://agilestyle.iteye.com/blog/2425203 map private static void mapTest() { List<Integer> list = Arrays.asList(1, 2, 3, 4, 5, 6, 7); List<Integer> result = list.stream().map(i -> i * 2).collect(Collectors.toList()); System.out.println(result); } Console Output [2, 4, 6, 8, 10, 12, 14] f…

2018-06-19 21:46 · FP · 评论(0)

Stream - Filter

原创转载请注明出处: http://agilestyle.iteye.com/blog/2425202 Filter private static void filterTest() { List<Integer> list = Arrays.asList(1, 2, 3, 4, 5, 6, 7); List<Integer> result = list.stream().filter(i -> i % 2 == 0).collect(Collectors.toList()); System.out.println(result); } Distinct private static voi…

2018-06-19 21:34 · FP · 评论(0)

Stream - Hello World

原创转载请注明出处: http://agilestyle.iteye.com/blog/2424918 Definition A short definition is “ a sequence of elements from a source that supports data processing operations. ” Sequence of elements — Like a collection, a stream provides an interface to a sequenced set of values of a specific element type. B…

2018-06-13 21:41 · FP · 评论(0)

Lambda Expression - Method Reference

原创转载请注明出处: http://agilestyle.iteye.com/blog/2424849 Examples of lambdas and method reference equivalents There are three main kinds of method references: 1. A method reference to a static method (for example, the method parseInt of Integer, written Integer::parseInt) 2. A method reference to an ins…

2018-06-12 21:23 · FP · 评论(0)