Answer the question
In order to leave comments, you need to log in
Why does the compiler see nothing after declaring an array?
public class Sorting {
static int getMin(int[] array, int first, int last) {
int min = array[first];
for (int i = first + 1; i <= last; i++) {
if (array[i] < min) {
min = array[i];
}
}
return min;
}
static int[] sortBySelect(int[] array) {
int i = 0;
int[] result = new int[array.length];
while (i < array.length) {
result[i] = getMin(array, i, array.length - 1);
}
return result;
}
public static void main(String[] args) {
int[] myArray = new int[] {7, 5, 1, 4, 9, 2, 6, 10, 3, 8};
int[] newArray = sortBySelect(myArray);
for (int i = 0; i < newArray.length; i++) {
System.out.println(myArray[i]);
}
}
}
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question