I'm trying to create a simple generic method that swaps two entries in an array but when I call the method it gives the the following error. What am I missing? I'm sure it's an easy fix I just can't see it.
Sorting.java
package testing;
import java.util.Comparator;
public class Sorting {
public static <T> void swap(T[] array, int left, int right){
T temp = array[right];
array[right] = array[left];
array[left] = temp;
}
}
SortTest.java
package testing;
import static testing.Sorting.*;
public class SortTest {
public static void main(String[] args){
int[] nums = {5, 12, 3, 7, 2};
swap(nums, 0, 1);
}
}