# Java冒泡排序

>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>

http://fanshuyao.iteye.com/

```/**
* 冒泡排序
* @param intArray 排序的数组
* @param sortType 排序类型（降序：desc，升序：null或其他值，即默认为升序）
*/
public final static void BubbleSort(int[] intArray, String sortType){
if(intArray != null){
for (int i = 0; i < intArray.length-1; i++) {
for (int j = 0; j < intArray.length-i-1; j++) {
if(("desc").equalsIgnoreCase(sortType)){
if(intArray[j] <= intArray[j+1]){
int temp = intArray[j];
intArray[j] = intArray[j+1];
intArray[j+1] = temp;
}
}else{
if(intArray[j] > intArray[j+1]){
int temp = intArray[j];
intArray[j] = intArray[j+1];
intArray[j+1] = temp;
}
}
}
System.out.println("第"+i+"次排序：");
for (int k = 0; k < intArray.length; k++) {
if(i==k){
System.out.print("@");
}
System.out.print(intArray[k]+" ");
}
System.out.println("");
}
}
}```

>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>

http://fanshuyao.iteye.com/

Java冒泡排序

• 0

开心

• 0

板砖

• 0

感动

• 0

有用

• 0

疑问

• 0

难过

• 0

无聊

• 0

震惊

public class Maopao { // 初始化数组的数据 private static int al[] = { 5, 9, 6, 7, 8, 10, 4, 3