//冒泡排序函数1
publicstaticvoidbubbleSort1(Comparable[]data){
intposition,scan;
Comparabletemp;
for(position=data.length-1;position>=0;position--){
for(scan=0;scan<=position-1;scan++){
if(data[scan].compareTo(data[scan+1])<0){
temp=data[scan];
data[scan]=data[scan+1];
data[scan+1]=temp;
}
}
}
}
//冒泡排序函数2
publicstaticint[]bubbleSort2(int[]m){
intintLenth=m.length;
for(inti=0;i
for(intj=0;j
inta=m[j];
intb=m[j+1];
if(a{
m[j]=b;
m[j+1]=a;
}
}
}
returnm;
}
publicstaticvoidmain(String[]args){
//冒泡排序1
Comparable[]c={4,9,23,1,45,27,5,2};
bubbleSort1(c);
for(inti=0;i
System.out.println("*******************");
//冒泡排序2
int[]b={4,9,23,1,45,27,5,2};
int[]e=bubbleSort2(b);
for(intj=0;j
}
}