Write BubbleGeneric with two versions of the same sort:
public static <E extends Comparable<E>> void bubbleSort(E[] list)
public static <E> void bubbleSort(E[] list, Comparator<? super E> order)
The first must simply call the second with Comparator.naturalOrder(). The sort stops as soon as a whole pass makes no swap; count the passes and the swaps.
main reads a line of words and prints: the words in natural order; the words by length, then alphabetically; what happens when the already sorted array is sorted again; and the lengths of the words, largest first (an Integer[] sorted with Comparator.reverseOrder()). For the input
pear fig banana kiwi apple date
the program prints
Natural order: [apple, banana, date, fig, kiwi, pear] (5 passes, 11 swaps)
By length, then alphabet: [fig, date, kiwi, pear, apple, banana] (5 passes, 8 swaps)
Sorting the sorted array again: 1 pass, 0 swaps
Word lengths, largest first: [6, 5, 4, 4, 4, 3]