Im trying to perform an operation and add those values in int[].
I collected those values in Stream, but while printing those values, im getting exception that stream is closed.
My Code below:
import java.util.*;
import java.util.stream.*;
import java.util.function.Supplier;
public class Main
{
public static void main (String[]args)
{
IntStream mystream = IntStream.of (3, 4, 5, 9, 18, 54, 8, 7, 14, 3);
Stream < int[] > p =
mystream.boxed ().flatMap (a->mystream.mapToObj (b->{
return new int[]{a, b,
(int)
Math.
sqrt ((a * a) + (b * b))};}));
Supplier < Stream < int[] >> streamSupplier = ()->p;
streamSupplier.get ().forEach (t->System.out.
println (t[0] + ", " + t[1] +
", " + t[2]));
}
}