Note: ArrayOperation.java uses unchecked or unsafe operations. Note: Recompile with -Xlint:unchecked for details.
public class ArrayOperation{
public static void sort(Comparable[] c){
for (int i=1;i<c.length;i++){
Comparable key = c[i];
int p = i;
while (p>0 && key.compareTo(c[p-1])<0){
c[p]=c[p-1];
p--;
}
c[p] = key;
}
}
}
you have to provide type parameter for java.lang.comparable, If you check the API for java.lang.Comparable, it expects a type parameter.
Interface Comparable<T>
thus, your method signature should be if you want compile time warnings to disappear.
public static void sort(Comparable<SomeType>[] c){
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With