Repeat the problem of Exercise P17.4, but require that the array elements implement the Comparable interface.

Complete the following file:

PairUtil.java

Use the following files:

MinMaxTester.java

public class MinMaxTester
{
   public static void main(String[] args)
   {
      String[] words = 
      {
         "Mary", "had", "a", "little", "lamb"
      };

      Pair<String, String> mm = PairUtil.minmax(words);
      System.out.println(mm.getFirst());
      System.out.println("Expected: Mary");
      System.out.println(mm.getSecond());
      System.out.println("Expected: little");
   }
}

Pair.java

public class Pair<T, S>
{
   private T first;
   private S second;

   public Pair(T firstElement, S secondElement)
   {
      first = firstElement;
      second = secondElement;
   }

   public T getFirst()
   {
      return first;
   }
   
   public S getSecond()
   {
      return second;
   }
}