我必须在冒泡排序中按降序对一串名称进行排序。我试过了,但它不工作。这是我到目前为止所拥有的:
public static void bubbleSort(Student[] array)
{
for(int i=(array.length); i>0; i--)
{
for(int j=1; j<(array.length-i); j++)
{
if( array[j].getName().compareTo(array[j+1].getName())<0)
{
Student Temp = array[j];
array[j] = array[j+1];
array[j+1] = Temp;
}
}
}
}