java - How could i turn this into a loop? -


this question has answer here:

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

Popular posts from this blog

html - Styling progress bar with inline style -

java - Oracle Sql developer error: could not install some modules -

How to use autoclose brackets in Jupyter notebook? -