I'm having a problem when invoking a method from another class. This is the code I'm using:
Contact[] database=players1();
System.out.println(sortalg[i]);
try {
Method method = Sorting.class.getMethod("selectionSort", Comparable[].class);
method.invoke(database);
}
This is the method I want to invoke:
public static void selectionSort (Comparable[] data)
{
int min;
for (int index = 0; index < data.length-1; index++)
{
min = index;
for (int scan = index + 1; scan < data.length; scan++)
if (data[scan].compareTo(data[min]) < 0)
min = scan;
swap(data, min, index);
}
}
And this is the error I get:
java.lang.IllegalArgumentException: wrong number of arguments
What arguments do I have to add?