Filter non-null strings

    0

    10

    filterstream
    Java Public Recipes

    Filter strings that are non-null from a list

    import java.util.List;
    
    // Filter string that have a non-null length
    List<String> newList = initialList.stream().filter(p -> s.length > 0).collect(Collectors.toList());
    Codiga Logo
    Codiga Hub
    • Rulesets
    • Playground
    • Snippets
    • Cookbooks
    Legal
    • Security
    • Privacy Policy
    • Code Privacy
    • Terms of Service
    soc-2 icon

    We are SOC-2 Compliance Certified

    G2 high performer medal

    Codiga – All rights reserved 2022.