The goal is to read 10 values of a given vector, and then create another vector that has the same values as the first vector, but in inverted order, for example, the first value of the 1st vector is the tenth of the 2nd vector, the second value of the 1st vector is the penultimate of the 2nd vector, and so on. I tried to do however the second vector always has a value of 0. I know I have to use for
for this, but I do not know if I used it correctly.
public static void main(String[] args) {
int [] firstArray = new int [10];
int [] secondArray = new int [10];
for (int i = 0; i < firstArray.length; i++) {
firstArray[i] =(int)Math.round(Math.random()*50); //Gerando valores aleatórios
}
//Passando valores
for (int i = 9; i <= 0; i--) {
for (int j = 0; j < secondArray.length; j++) {
secondArray[j] = firstArray[i];
break;
}
}
//Apresentar valores
System.out.println("\nPrimeiro Array:");
for (int i = 0; i < firstArray.length; i++) {
System.out.print(firstArray[i]+"; ");
}
System.out.println("\nSegundo Array:");
for (int i = 0; i < secondArray.length; i++) {
System.out.print(secondArray[i]+"; ");
}
System.out.println("");
}