冒泡排序
package blog; import java.util.Arrays; public class bubble { public static void main(String[] args) { int[] a = new int[] {9,5,7,4,0,3}; asc(a); System.out.println(Arrays.toString(a)); } static void asc(int [] arr) { int temp; for(int i=0;i<arr.length-1;i++) { for(int j=0;j<arr.length-1-i;j++) { if(arr[j+1] < arr[j]) { temp = arr[j]; arr[j] = arr[j+1]; arr[j+1] = temp; } } } } } 来源: https://www.cnblogs.com/wangsihui/p/11877106.html