+ 1
Can anyone tell me how this code works. Step by step?
public class Program { public static void main(String[] args) { int[] a = {10,3,2}; for(int i = 1; i<2; i++){ a[0]/=a[i]; } System.out.println(a[0]); } }
1 Respuesta
+ 5
From the loop, it is obvious that it runs only once for the value i = 1, so
a[0] /= a[i];
is
a[0] /= 3
10 divided by 3 is 3. 3 is assigned to a[0]. a[0] is printed. 3 is printed.