-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathSelectSortApp2.java
More file actions
35 lines (29 loc) · 842 Bytes
/
SelectSortApp2.java
File metadata and controls
35 lines (29 loc) · 842 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
import java.util.Arrays;
class MySelectSort2 {
private int[] array = {4, 2, 9, 3, 1, 3, 11, 8};
int[] sort(int[] array) {
int min, temp;
for (int i = 0; i < array.length; i++) {
min = i;
for (int j = i + 1; j < array.length; j++) {
if(array[j] < array[min]){
min = j;
}
}
temp = array[min];
array[min] = array[i];
array[i] = temp;
}
return array;
}
public int[] getArray() {
return array;
}
}
public class SelectSortApp2 {
public static void main(String[] args) {
MySelectSort2 selectSort2 = new MySelectSort2();
selectSort2.sort(selectSort2.getArray());
System.out.println(Arrays.toString(selectSort2.getArray()));
}
}