You could try this:
for(int i = 1; i < 10; i++)
System.out.println(i/10f);
0.1
0.2
0.3
0.4
0.5
0.6
0.7
0.8
0.9
What you are seeing is a product of inaccuracies that are intrinsic to floats, which naturally build up if you add them continuously, as you do in the code you posted. If we use int
s in the loop instead, we avoid the float-addition and, therefore, also the error build-up.