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

stream #2

Open
gao-classmate opened this issue Apr 13, 2022 · 0 comments
Open

stream #2

gao-classmate opened this issue Apr 13, 2022 · 0 comments

Comments

@gao-classmate
Copy link

@test
public void simpleTest(){
List numbers = Arrays.asList(1, 2, 3);
int[] factor = new int[] { 2 };
Stream stream = numbers.stream()
.map(e -> e * factor[0]);
factor[0] = 0;
stream.forEach(System.out::println);
}
作者大大,请问这个为什么改了factor[0]的数值,遍历出来的流数值就会改变呢? 明明map映射的时候,采用的是factor[0]=2的数值啊。无法理解,能解释一下吗?

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

1 participant