![]() |
VOOZH | about |
Using Arrays.stream() :
Syntax :public static <T> Stream<T> getStream(T[] arr)
{
return Arrays.stream(arr);
}
where, T represents generic type.
Example 1 : Arrays.stream() to convert string array to stream.
Geeks for Geeks
1 2 3 4 5
3 5 6 8 9 1.0 2.0 3.0 4.0 5.0
Using Stream.of(), IntStream.of(), LongStream.of() & DoubleStream.of() :
Syntax :public static <T> Stream<T> getStream(T[] arr)
{
return Stream.of(arr);
}
where, T represents generic type.
Syntax of other functions is similar
Note : For object arrays, Stream.of() internally uses Arrays.stream().
Example 1 : Arrays.stream() to convert string array to stream.
Geeks for Geeks
1 2 3 4 5
3 5 6 8 9 1.0 2.0 3.0 4.0 5.0