---
type: archive
area: archive
status: archived
date: 2026-05-03
created: 2026-05-03
updated: 1980-01-01
tags:
  - archive
---
## Stream 
- Operation can be sequential or parallel
- Stream ends as soon as the result is determined
- use func interfaces and can be implemented as lambda expressions
- Stream use generics
- Stream can be obtained from any collections and array or static methods of Stream class.
![[img-20240815-025723-2e07d4b8.png]]

### Example
![[img-20240815-122844-6c43f8ee.png]]

- Consumer do something to the object that we gave
- Predicate is simply a condition wrote in lambda expression syntax to use it with filter.

![[img-20240815-124235-f0f34f7b.png]]

![[img-20240815-125711-15016ef4.png]]

![[img-20240815-130851-24dcccd9.png]]
- Reduce produces a single result from the stream.
- when using reduce with an initial value is used to get it in case this reduce gave in result nothing. 
- Supplier is just an interface that generate contents
- Collectors and reduces are the same but collectors uses an intermediate before giving the result.
![[img-20240815-160124-7cbfc689.png]]
- There is also Collectors.flatMapping() methods that usind to create a HashMap of some data also .filtering that do the same.

![[img-20240815-162018-e286291c.png]]
- In parallel do not perform an operation on shared resource or modfiy a shared ressource 
 
![[img-20240815-162338-80289c0e.png]]

- Spliterator is analogue of Iterator with parallel processing capability.