Why is the output of this program 1 1 2 2 3 3
instead of 1 1 2 2 3 1
class Scratch {
public static void main(String[] args) {
int[] a = { 1, 2, 3, 4, 5, 3 };
for (int i = 0; i < 6; i++)
System.out.print(a[i / 2] + " ");
}
}
When you divide 3/2 it equals 1.5, which I thought Java only took the first value of an integer number. What's going on?