Class Pair<FIRST,​SECOND>

  • Type Parameters:
    FIRST - type of the first object in the pair.
    SECOND - type of the second object in the pair.
    Direct Known Subclasses:
    SameTypePair

    public class Pair<FIRST,​SECOND>
    extends Object
    An immutable pair of objects.
    • Constructor Detail

      • Pair

        public Pair​(FIRST first,
                    SECOND second)
        Construct a new pair.
        Parameters:
        first - first element, can be null.
        second - second element, can be null.
    • Method Detail

      • of

        public static <FIRST,​SECOND> Pair<FIRST,​SECOND> of​(FIRST first,
                                                                       SECOND second)
      • first

        public FIRST first()
        Return the first element of the pair.
        Returns:
        first element, can be null.
      • second

        public SECOND second()
        Return the second element of the pair.
        Returns:
        second element, can be null.
      • hashCode

        public int hashCode()
        Overrides:
        hashCode in class Object