Is there a way in java to create a string with a specified number of a specified character? In my case, I would need to create a string with 10 spaces. My current code is:
If you want only spaces, then how about:
String spaces = (n==0)?"":String.format("%"+n+"s", "");
which will result in abs(n) spaces;