Copy an existing list into an immutable list



    Java Public Recipes

    This creates a copy of the existing list and assigns the new list to newlist.

    import java.util.List;
    List newlist = List.copyOf(existingList);
    Codiga Logo
    Codiga Hub
    • Rulesets
    • Playground
    • Snippets
    • Cookbooks
    • 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.