Junior — Middle
Millist programmeerimislähestikku kasutab Java Stream API liides?
sobes.tech AI
Vastus AI-lt
Java's Stream API implements a functional programming approach for processing sequences of data. It allows working with collections and other data sources declaratively, using chains of operations such as filtering, mapping, sorting, and aggregation.
Main features of the Stream API:
- Enables writing concise and readable code for data processing.
- Supports lazy computations — operations are performed only when necessary.
- Facilitates easy implementation of parallel data processing.
Example of using the Stream API:
List<String> names = Arrays.asList("Anna", "Bob", "Charlie", "David");
List<String> filtered = names.stream()
.filter(name -> name.startsWith("A"))
.map(String::toUpperCase)
.collect(Collectors.toList());
System.out.println(filtered); // [ANNA]
Therefore, the Stream API is a tool for functional, declarative, and efficient programming with collections in Java.