java - How could i turn this into a loop? -
this question has answer here:
- how can pad integers zeros on left? 12 answers
public string tostring() { if(zipcode < 10000) { if(zipcode < 1000) { if(zipcode < 100) { if(zipcode < 10) { return "0" + "0" + "0" + "0" + integer.tostring(zipcode); } return "0" + "0" + "0" + integer.tostring(zipcode); } return "0" + "0" + integer.tostring(zipcode); } return "0" + integer.tostring(zipcode); } else { return integer.tostring(zipcode); } }
is there loop add 0 in front of string depending on exponent of 10 number stored in zipcode is? i'm not looking rid of zeroes i'm looking keep zeroes, zeroes taken away.
string.format("%05d", number);
it's implemented yet.
Comments
Post a Comment