Real-World Use Cases and Examples
// Spring Web Example @RestController public class HelloController { @GetMapping("/hello") public String hello() { return "Hello, World!"; } }List<String> names = Arrays.asList("Alice", "Bob", "Charlie"); names.stream().filter(name -> name.startsWith("A")).forEach(System.out::println); // Output: AliceList<Integer> numbers = Arrays.asList(1, 2, 3, 4, 5, 6, 7, 8, 9, 10); int sum = numbers.parallelStream().mapToInt(Integer::intValue).sum(); System.out.println("Sum: " + sum); // Output: Sum: 55
Last updated