package study.sort;
import java.util.Arrays;
public class SelectionSort {
public static void main(String[] args) {
int[] arr = {6,8,3,7,5,9,1};
for (int i = 0; i < arr.length-1; i++) {
int minIndex = i;
for (int j = i; j < arr.length; j++) {
if (arr[minIndex] > arr[j]){
minIndex = j;
}
}
int temp = arr[i];
arr[i] = arr[minIndex];
arr[minIndex] = temp;
}
System.out.println(Arrays.toString(arr));
}
}
07-08
1万+
![](https://csdnimg.cn/release/blogv2/dist/pc/img/readCountWhite.png)
02-21
4563
![](https://csdnimg.cn/release/blogv2/dist/pc/img/readCountWhite.png)
08-18
7873
![](https://csdnimg.cn/release/blogv2/dist/pc/img/readCountWhite.png)
08-24
684
![](https://csdnimg.cn/release/blogv2/dist/pc/img/readCountWhite.png)