Write GenericTools with four generic methods, giving each the weakest condition on its type parameter that makes it compile:
max(E[][] grid)— the largest element of a two-dimensional array;max(ArrayList<E> list)— the largest element of a list;distinct(ArrayList<E> list)— a new list with the first occurrence of each element;sort(ArrayList<E> list)— sorts the list itself (selection sort).
Three of them need <E extends Comparable<E>>; one works with a plain <E>. Which one, and why?
main reads rows cols, a grid of integers, then a line of words. For the input
2 3
4 9 2
7 -1 8
pear apple fig pear kiwi apple fig
the program prints
Largest number in the grid: 9
Distinct words: [pear, apple, fig, kiwi]
Sorted: [apple, fig, kiwi, pear]
Largest word: pear
Largest of a String grid: west