-
Notifications
You must be signed in to change notification settings - Fork 19
Open
Labels
bugSomething isn't workingSomething isn't workingslugNew or updated pattern snippet (category/slug.json)New or updated pattern snippet (category/slug.json)
Description
Category
collections
Pattern slug
stream-toarray-typed
Which code is affected?
Both
Type of issue
Other
Describe the issue
The old code only shows how a list is converted to an array, without the filtering which happens in the stream variant.
This could quite simply be done with String[] arr = list.toArray(new String[0]);
So either we also filter in the old version - which would then indeed require a for loop. Or the we don't filter in the new version, in which case I'd argue that getNames().toArray(new String[0]); is actually simpler/better than getNames().stream().toArray(String[]::new);.
Suggested fix
JDK version tested
No response
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
bugSomething isn't workingSomething isn't workingslugNew or updated pattern snippet (category/slug.json)New or updated pattern snippet (category/slug.json)