Class Pair<T>

  • Type Parameters:
    T - The type of the objects.

    public class Pair<T>
    extends Object
    A pair of objects of the same type.
    • Field Detail

      • first

        public T first
        The first object.
      • second

        public T second
        The second object.
    • Constructor Detail

      • Pair

        public Pair()
        Creates a pair of null objects.
      • Pair

        public Pair​(T first,
                    T second)
        Creates a pair with the objects specified in the arguments.
        Parameters:
        first - The first object.
        second - The second object.
    • Method Detail

      • get

        public T get​(int index)
              throws IllegalArgumentException
        Accesses an object by its index. The first object has index 0 and the second object has index 1.
        Parameters:
        index - The index of the object to be accessed.
        Returns:
        The first object if index is 0; the second object if index is 1.
        Throws:
        IllegalArgumentException - If index is neither 0 or 1.