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

Django REST Framework perform_create: You cannot call `.save()` after accessing `serializer.data` -

Why does Go error when trying to marshal this JSON? -