Bom dia!
por gentileza se alguém puder me ajudar a identifica o erro no código abaixo.
Necessito inverter os valores do vetor com um método.
O método faz a inversão, porem ao imprimir imprime valores a mais.
613467458923476134674589234761346745892347613467458923476134674589234761346745892347613467458923476134674589234761346745892347
public class Inverte_Vetor {
public static int VETOR1[] = { 7, 4, 23, 89, 45, 67, 34, 1, 6 };
public static void main(String[] args) {
inverteVetor(VETOR1);
}
public static void inverteVetor(int[] vet) {
int[] vetInvertido = new int[VETOR1.length];
for (int f = 0; f < vetInvertido.length; f++) {
for (int i = vet.length - 1; i >= 0; i--) {
vetInvertido[f] = vet[i];
System.out.print(vet[i]);
}
}
}
}