Class Lists


  • public final class Lists
    extends Object
    Utility methods related to Lists.
    Author:
    Yvonne Wang, Alex Ruiz, Joel Costigliola
    • Constructor Detail

      • Lists

        private Lists()
    • Method Detail

      • newArrayList

        @SafeVarargs
        public static <T> ArrayList<T> newArrayList​(T... elements)
        Creates a mutable ArrayList containing the given elements.
        Type Parameters:
        T - the generic type of the ArrayList to create.
        Parameters:
        elements - the elements to store in the ArrayList.
        Returns:
        the created ArrayList, of null if the given array of elements is null.
      • newArrayList

        public static <T> ArrayList<T> newArrayList​(Iterable<? extends T> elements)
        Creates a mutable ArrayList containing the given elements.
        Type Parameters:
        T - the generic type of the ArrayList to create.
        Parameters:
        elements - the elements to store in the ArrayList.
        Returns:
        the created ArrayList, or null if the given Iterable is null.
      • newArrayList

        public static <T> ArrayList<T> newArrayList​(Iterator<? extends T> elements)
        Creates a mutable ArrayList containing the given elements.
        Type Parameters:
        T - the generic type of the ArrayList to create.
        Parameters:
        elements - the elements to store in the ArrayList.
        Returns:
        the created ArrayList, or null if the given Iterator is null.
      • newArrayList

        public static <T> ArrayList<T> newArrayList()
        Creates a mutable ArrayList.
        Type Parameters:
        T - the generic type of the ArrayList to create.
        Returns:
        the created ArrayList, of null if the given array of elements is null.
      • emptyList

        @Deprecated
        public static <T> List<T> emptyList()
        Deprecated.
        Type Parameters:
        T - the generic type of the List.
        Returns:
        an empty, immutable List.