Currently whenever I need to create stream from an array, I do
String[] array = {"x1", "x2"};
Arrays.asList(array).stream();
Is there some direct way to create stream from an array?
Currently whenever I need to create stream from an array, I do
Is there some direct way to create stream from an array? |
||||
|
You can use Arrays.stream E.g.
EDIT You can also use
But note
When you pass primitive array to
and When you pass primitive array to
Hence you get different results. |
|||||||||||||||||||||
|
Alternative to @sol4me's solution:
Of the difference between this and
where |
|||||||||||||||||||||
|
Or, if you are already have an array, you can also do
For primitive types use |
||||
|