I have to do a program to enter arrays in the main and then show the number plus its position, I wanted to enter arrays by the constructor and it does not leave me. Is there another way to do it?
public class IngresoDeEnteros {
private int numeros[];
private int dimension = 10;
public IngresoDeEnteros(int numeros []) {
this.numeros = numeros;
this.numeros = new int[dimension];
}
public void mostrarArrays() {
int posicion = 0;
for (int i = 0; i < numeros.length; i++) {
posicion = i;
System.out.println("vector : " +numeros[i] + "indice : "+ posicion);
}
}
}
public class PruebaIngresoDeEnteros {
public static void main(String[] args) {
IngresoDeEnteros array1[] = new IngresoDeEnteros{5, 10, 12,33 ,26 ,15,86,47,78,109};
array1.mostrarArrays();
}
}