//冒泡排序public static int[] bubbleSort(int[] arr){ int length = arr.length; for(int i = 0;iarr[j]){ int t = arr[i]; arr[i] = arr[j]; arr[j] = t; } } } return arr;}
// 测试public static void main(String[] args){ int[] arr = {4,2,3,1}; int[] newArr = bubbleSort(arr); for (int num:newArr) { System.out.println(num); }}