Class Collections2


public final class Collections2 extends Object
Utility methods for manipulating Collections and their subclasses/implementations.
  • Method Details

    • toList

      public static <T> List<T> toList(Iterator<T> iterator)
      Creates a List from the elements remaining in iterator.
    • toList

      public static <T> List<T> toList(Iterable<T> iterable)
      Converts the iterable into a new List.
    • toImmutableList

      public static <T> List<T> toImmutableList(Iterable<T> iterable)
      Converts the iterable into a new immutable List.
    • immutableMapCopy

      public static <K, V> Map<K,V> immutableMapCopy(Map<K,V> map)
      Copies the elements of map to a new unmodifiable map.
    • immutableListCopy

      public static <V> List<V> immutableListCopy(List<V> list)
      Copies the elements of list to a new unmodifiable list.
    • asImmutableList

      public static <V> List<V> asImmutableList(V... values)
      Copies the values to a new unmodifiable list.
    • toString

      public static String toString(Iterator<?> iterator)
      Creates a human readable string from the remaining elements in iterator.

      The output should be similar to Arrays#toString(Object[])