Skip to content

Codes #297

@siddharthrgade21-a11y

Description

@siddharthrgade21-a11y

import java.util.*;
import java.util.stream.Collectors;

public class StreamAdvance {
public static void main(String[] args) {
List names = Arrays.asList("Alice", "Bob", "Charlie", "David", "Edward", "Alice");

    // Advanced filter: Unique names longer than 3 chars, sorted, converted to uppercase
    List<String> result = names.stream()
            .filter(name -> name.length() > 3)
            .distinct()
            .map(String::toUpperCase)
            .sorted()
            .collect(Collectors.toList());

    // Grouping names by their starting letter
    Map<Character, List<String>> grouped = names.stream()
            .collect(Collectors.groupingBy(name -> name.charAt(0)));

    System.out.println("Processed List: " + result);
    System.out.println("Grouped by Letter: " + grouped);
}

}

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions