If you want primitive int
values, do not call IntStream::boxed
as that produces Integer
objects by boxing.
Simply use Random::ints
which returns an IntStream
:
int[] array = new Random().ints(size, lowBound, highBound).toArray();
If you want primitive int
values, do not call IntStream::boxed
as that produces Integer
objects by boxing.
Simply use Random::ints
which returns an IntStream
:
int[] array = new Random().ints(size, lowBound, highBound).toArray();