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
- Java List — The collection interface for an ordered sequence of elements that may contain duplicates, with ArrayList as the usual implementation.
- Java Set — The collection interface for a group of unique elements, where adding a duplicate has no effect.
- Java Map — The collection interface that associates each unique key with one value, replacing the old value when a key is stored again.
- Stream API — The standard-library toolkit for describing a sequence of data-processing steps, such as filter, map and collect, over a source like a list.
Taught in
- The Collections Framework — Modern Java: Virtual Threads & High-Throughput Services
- The Streams API — Modern Java: Virtual Threads & High-Throughput Services
- Scope, var And Immutable Objects — Oracle Certified Professional: Java SE 21 Developer (1Z0-830) Exam Prep
- Sprint: Lambdas And Streams — Oracle Certified Professional: Java SE 21 Developer (1Z0-830) Exam Prep
- Concurrent Collections And Parallel Streams — Oracle Certified Professional: Java SE 21 Developer (1Z0-830) Exam Prep
- Sprint: Modules And Concurrency — Oracle Certified Professional: Java SE 21 Developer (1Z0-830) Exam Prep