Setting decimal as increment in for loop. Is there a way to set increment of the value by a decimal? Eg. (x=0, x<=10, x+=0.25) | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
0

Setting decimal as increment in for loop. Is there a way to set increment of the value by a decimal? Eg. (x=0, x<=10, x+=0.25)

20th Oct 2016, 4:40 AM
Eric Powpowpow Ang
Eric Powpowpow Ang - avatar
2 Answers
+ 6
//It works :D public class Program { public static void main(String[] args) { double x; for(x=0;x<10;x+=0.25) System.out.println(x); } }
20th Oct 2016, 10:26 AM
Lara
Lara - avatar
0
yes you can do it!!
23rd Oct 2016, 6:13 AM
Naga Nikhil
Naga Nikhil - avatar