Hello,
I am having a real hard to trying to figure out how to use generics
I have the following insertion sort method defined
public static <T extends Comparable<? super T>> void insertionSort (T[] data) { for (int index = 1; index < data.length; index++) { T key = data[index]; int position = index; /** Shift larger values to the right */ while (position > 0 && data[position-1].compareTo(key) > 0) { data[position] = data[position-1]; position--; } data[position] = key; } }
I am trying to call it in the following manner where class Card is previously defined
private static List< Card > list; // declare List that will store Cards public static void main( String args[] ) { DeckOfCards cards = new DeckOfCards(); cards.printCards(); InsertionSort.insertionSort(list); } // end main
However, I get the following error:
The method insertionSort(T[]) in the type InsertionSort is not applicable for the arguments (List<Card>)
Any help