Sunday, 29 September 2013

separate integers in row with commas?

separate integers in row with commas?

I feel like there is a simple way to do this but i'm trying to separate
the numbers in this row with commas except the last one(being 20).
public class ForLoops
{
public static void main(String[] args)
{
final int MAX = 21;
for (int row = 1; row<MAX; row++)
System.out.print(row);
}
}
instead of displaying 123456789101112(ect.) i need it to display
1,2,3,4,5,6,7,8,9,10,11,12(etc). any advise?

No comments:

Post a Comment