InterviewSolution
| 1. |
What are the most commonly used Intermediate operations? |
|
Answer» Filter(Predicate<T>) - Allows selective processing of Stream elements. It returns elements that are satisfying the supplied condition by the predicate. map(Funtion<T, R>) - Returns a new Stream, transforming each of the elements by applying the supplied MAPPER function.= SORTED() - Sorts the input elements and then passes them to the next stage. distinct() - Only pass on elements to the next stage, not PASSED yet. limit(long maxsize) - Limit the stream size to maxsize. skip(long start) - Skip the initial elements till the start. peek(Consumer) - Apply a consumer WITHOUT MODIFICATION to the stream. flatMap(mapper) - Transform each element to a stream of its constituent elements and flatten all the streams into a single stream. |
|