Java Homework. I'm help understanding why my code will compile but leaves notes in the compiler about array problems?

java

Solution

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){

Problem

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; } } ``` }

Original source