import java.util.Arrays;
import java.util.Random;
public class ArraySort {
public static void main(String[] args) {
int[] arr = new int[10];
for (int i = 0; i < arr.length; i++) {
arr[i]=new Random().nextInt(100);
}
for(int j=0;j<arr.length-1;j++){
for (int i = 0; i < arr.length-1-j; i++) {
if(arr[i]>arr[i+1]){
//交换
int t = arr[i];
arr[i]=arr[i+1];
arr[i+1]=t;
}
}
}
System.out.println(Arrays.toString(arr));
}
}
原文:https://www.cnblogs.com/C33baby/p/12781337.html