I have two classes and an interface. I created methods in the interface and overrode them in a class that implements the interface. Now I am trying to import these methods into another class. For some reason they methods are not found. Very frustrating because I do not know why. The interface, overriding class, and class that imports the methods are below in that exact order. Why can't they import?:
public interface SortInterface {
public abstract void recursiveSort(int[] list);
public abstract void iterativeSort(int[] list);
int getCount();
long getTime();
}
overriding class:
public class YourSort implements SortInterface{
@Override
public void iterativeSort(int[] list) {
for(int i =1; i< list.length; i++){
int temp = list[i];
int j;
for (j = i-1; j>=0 && temp < list[j]; j--)
list[j+1] = list[j];
list[j+1] = temp;
}}
public static void recursiveSort(int array[], int n, int j) {
if (j < n) {
int i;
int temp = array[j];
for (i=j; i > 0 && array[i-1] > temp; i--) array[i] = array[i-1];
array[i] = temp;
recursiveSort(array,n, j+1); }}
@Override
public void recursiveSort(int[] list) {
int j = list.length;
int n=0;
if (j < n) {
int i;
int temp = list[j];
for (i=j; i > 0 && list[i-1] > temp; i--) list[i] = list[i-1];
list[i] = temp;
recursiveSort(list,n, j+1); }
}
@Override
public int getCount() {
throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates.
}
@Override
public long getTime() {
throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates.
}
}
importing class:
public class SortMain {
static int[] b;
static int[] c;
/**
* @param args the command line arguments
*/
public static void main(String[] args) {
b = new int[5];
b[0]= 8;
b[1]=5;
b[2]=9;
b[3]=4;
b[4]=2;
recursiveSort(b);
c = new int[5];
c[0]= 8;
c[1]=5;
c[2]=9;
c[3]=4;
c[4]=2;
recursiveSort(b);
for(int i = 0; i<5; i++){
System.out.println(b[i]);
}
iterativeSort(c);
System.out.println("");
for(int i = 0; i<5; i++){
System.out.println(c[i]);
}
}
}