Assume I have an infinite Stream.
IntStream istream = IntStream.iterate(0, i -> i + 1).limit(100);
Stream<Integer> boxedStream = istream.boxed();
Does the boxed()
method preserve order? Probably yes, but I cannot find it in the documentation.
Assume I have an infinite Stream.
IntStream istream = IntStream.iterate(0, i -> i + 1).limit(100);
Stream<Integer> boxedStream = istream.boxed();
Does the boxed()
method preserve order? Probably yes, but I cannot find it in the documentation.
Actually every intermediate operation preserves an order by default. The only exceptions are:
unordered()
which removes the ordering constraint.sorted()
which changes the order.When it's not explicitly specified, you can assume that operation keeps the order. Even distinct()
keeps the order, though it adds much complexity for parallel stream.