Home > other >  For Output format using java
For Output format using java

Time:10-31

for (i = 0; i < 10; i ) {

System.out.print(i);

}

I want an horizontal output such as;

0 1 2 3 4 5 6 7 8 9

How can I do that using Java?

Thanks.

CodePudding user response:

print number with space for each iteration.

for (i = 0; i < 10; i   ) {

System.out.print(i " ");

}

CodePudding user response:

If u want to print successive string using java, the best way is to use print and print the string with space, so that it doesnt get printed all clumped up. For example:

for (v = 0; v < 10; v   ) {

System.out.print(v   " ");

}
  • Related