i need to concatenate 8-length() of 0's before a string that has as length: lenght(). In other words i have to write a loop that will print out (if needed!) 0's in front of a string ... in order to make it a 8 charachter string
P.S. I can not believe that java does not have a function that prints a charachter n-times. Or does it?
Joined: Aug 20, 2001
It doesn't, but you can easily write your own:
Piscis Babelis est parvus, flavus, et hiridicus, et est probabiliter insolitissima raritas in toto mundo.
Joined: Jun 09, 2003
Another way, perhaps String pad = "00000000"; String str = "12345"; str = pad.substring(0,pad.length()-str.length())+str; System.out.println(str);