Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

疑问 #3

Open
xixifeng opened this issue Apr 24, 2018 · 2 comments
Open

疑问 #3

xixifeng opened this issue Apr 24, 2018 · 2 comments

Comments

@xixifeng
Copy link

Stream<String> stream = Stream.of("I", "love", "you", "too");
List<String> list = stream.collect(ArrayList::new,ArrayList::add,(t,u)-> {
			System.out.println("t:" + t+" u:" + u);
			t.addAll(u);
});
System.out.println(list);

谢谢, 你启发(正反参半)了我.

这个例子,collect的第三个参数并没有执行,若能举一个体现第三个参数作用的例子会更好.

@keanu9527
Copy link

Stream stream = Stream.of("I", "love", "you", "too").parallel();换成并行流时候,第三个参数会起作用

@mrdear
Copy link

mrdear commented Dec 4, 2018

@xixifeng 第三个是merge函数,在Stream并发时会对输入做切分,分别执行中间的过程,最后合并结果,这个时候就有效果了。

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants