Were now on arrays and the job is to do a list of numbers and then it would show the descending order of those numbers.
Here's the condition: A Nested Loop and a Decisive Structure.
I wasn't able to use this code:
for (iLoop = iNumber.length - 1; iLoop >= 0; iLoop--){
System.out.println("" + iNumber[iLoop]);
Because it wouldn't show a nested loop one nor any decisive structures.
I can't use any sort of method YET. Only the first for loop will do the loop for the array. Here's my code next:
int iX, iY, iLoop;
Scanner var = new Scanner(System.in);
int[]iNumber = new int [10];
for (int iIndex = 0; iIndex < iNumber.length; iIndex++){
System.out.print("Enter a number: ");
iNumber [iIndex] = var.nextInt();
}
for (iX = 0; iX < iNumber.length; iX++){
for (iY = iX + 1; iY < iNumber.length; iY++){
if (iNumber[iX] < iNumber[iY]){
iLoop = iNumber[iX];
iNumber[iX] = iNumber[iY];
iNumber[iY] = iLoop;
}
}
System.out.println("" + iNumber);
}
}
}
Now, I can't now think why the output is:
[I@1909752
[I@1909752
[I@1909752
[I@1909752
[I@1909752
[I@1909752
[I@1909752
[I@1909752
[I@1909752
[I@1909752
I don't know what to do again. Someone help me, thank you in advance.