Hi, habe ein kleines Problem mit folgender Compiler Warnmeldung:
Note: class x.java uses unchecked or unsafe operations.
Note: Recompile with -Xlint:unchecked for details:
Hier der Quellcode:
Hoffe jdm. kann mir behilflich sein
mfg c.k.
Note: class x.java uses unchecked or unsafe operations.
Note: Recompile with -Xlint:unchecked for details:
Code:
java:22: warning: [unchecked] unchecked call to compareTo(T) as a member of the raw type java.lang.Comparable
while(j >= 0 && a[j].compareTo(value) > 0)
java:34: warning: [unchecked] unchecked call to compareTo(T) as a member of the raw type java.lang.Comparable
if(a[i + 1].compareTo(a[i]) < 0)
Code:
import java.util.*;
public class x {
public static void insertionSort(Comparable[] a)
{
for(int i = 1; i < a.length; i++)
{
assert isSorted(a, 0, i-1):j;
Comparable value = a[i];
int k = i - 1;
while(j >= 0 && a[j].compareTo(value) > 0)
{
swap(a, j, j+1);
j--;
}
}
}
private static boolean isSorted(Comparable[] a, int low, int high)
{
for(int i = low; i < high; i++)
{
if(a[i + 1].compareTo(a[i]) < 0)
return false;
}
return true;
}
private static void swap(Comparable[] a, int x, int y)
{
Comparable temp = a[x];
a[x] = a[y];
a[y] = temp;
}
}
Hoffe jdm. kann mir behilflich sein
mfg c.k.