import java.util.*;
import java.util.stream.Collectors;
public class StreamExample {
public static void main(String[] args) {
List names = Arrays.asList("Alice", "Bob", "Charlie", "David", "Edward");
// Filter names longer than 4 chars, convert to uppercase, and collect to a Map
Map<Integer, List<String>> groupedByLength = names.stream()
.filter(name -> name.length() > 3)
.map(String::toUpperCase)
.collect(Collectors.groupingBy(String::length));
System.out.println(groupedByLength);
}
}
import java.util.*;
import java.util.stream.Collectors;
public class StreamExample {
public static void main(String[] args) {
List names = Arrays.asList("Alice", "Bob", "Charlie", "David", "Edward");
}