0
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 a loop that i could do that would add a zero in front of the string depending on what exponent of 10 the number stored in zipCode is? I'm not looking to get rid of the zeroes I'm looking to keep the zeroes, but the zeroes are taken away.

Ethan
  • 25
  • 4

1 Answers1

2
String.format("%05d", number);

It's implemented yet.

granmirupa
  • 2,780
  • 16
  • 27