encounter order

The order in which a collection or stream presents its elements, such as the insertion order of a List or LinkedHashSet.

In more detail

Some collections define an order and some, like HashSet, do not. Stream operations such as toList preserve encounter order when the source has one. If clients rely on order, choose a collection that guarantees it and say so in the contract.

Related terms

Taught in

References

Certification courses