In this case I am filling an array with random numbers. When I use a normal for the index in each iteration increases one by one, but with the for each I can not do that.
I attach the code
Scanner lector = new Scanner(System.in);
int nro;
System.out.println("Digite la cantidad de numeros con la que quiera llenar el arreglo de forma aleatoria");
nro = lector.nextInt();
int a[] = new int[nro];
/* for(int i = 0; i < nro; i++){
a[i] = (int) (Math.random()*100);
System.out.println("Indice " + i + " es igual " + a[i]);
}*/
for(int i : a){
a[i] = (int) (Math.random()*100);
System.out.println("Indice "+ (1+i) + " = " + a[i]);
}