This is the instruction in one of the exercises in our Java class. Before anything else, I would like to say that I \'do my homework\' and I\'m not just being lazy asking someon
This will surely help you.
int n[] = {4,6,9,1,7};
for(int i=n.length;i>=0;i--){
for(int j=0;j n[j+1]){
swapNumbers(j,j+1,n);
}
}
}
printNumbers(n);
}
private static void swapNumbers(int i, int j, int[] array) {
int temp;
temp = array[i];
array[i] = array[j];
array[j] = temp;
}
private static void printNumbers(int[] input) {
for (int i = 0; i < input.length; i++) {
System.out.print(input[i] + ", ");
}
System.out.println("\n");
}