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

Problem in one of the methods #1

Open
ghost opened this issue Oct 24, 2017 · 1 comment
Open

Problem in one of the methods #1

ghost opened this issue Oct 24, 2017 · 1 comment

Comments

@ghost
Copy link

ghost commented Oct 24, 2017

There is a problem with this line
return result.stream().mapToInt(i -> i).toArray();
i is not declared anywhere. What is its meaning ?

@technobium
Copy link
Owner

Hi,

Thanks for the comment. This is a valid method to convert the ArrayList to an array of int's. The "i" is inside the lambada expression and it is valid. It may be misleading because it has the same name as the "for (int i " variable. It could have been:

return result.stream().mapToInt(x -> x).toArray();

https://docs.oracle.com/javase/8/docs/api/java/util/stream/Stream.html

Hope this helps.

Best regards

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