Class Pair<T1,​T2>

  • All Implemented Interfaces:
    Map.Entry<T1,​T2>

    public class Pair<T1,​T2>
    extends Object
    implements Map.Entry<T1,​T2>
    An arbitrary pair of objects. Convenient implementation of Map.Entry.
    • Field Detail

      • first

        public T1 first
      • second

        public T2 second
    • Constructor Detail

      • Pair

        public Pair()
      • Pair

        public Pair​(T1 f,
                    T2 s)
    • Method Detail

      • of

        public static <L,​R> Pair<L,​R> of​(L left,
                                                     R right)

        Obtains an immutable pair of from two objects inferring the generic types.

        This factory allows the pair to be created using inference to obtain the generic types.

        Type Parameters:
        L - the left element type
        R - the right element type
        Parameters:
        left - the left element, may be null
        right - the right element, may be null
        Returns:
        a pair formed from the two parameters, not null
        Since:
        1.4