C Books Guide and List
C++ Books Guide and List
Best Java Books

3,749 questions

4,049 answers

114 comments

10,705 users

What is zero padding and How to pad with zeros rather than spaces?

0 votes
101 views
asked May 5, 2014 by sunny Expert (11,410 points)

1 Answer

0 votes
0 padds output with zeros rather than spaces.

Syntax

fmt.format("0%g\n", 123.1);

Example

The 0 flag causes output to be padded with zeros rather than spaces.

import java.util.Formatter;
public class Main {
  public static void main(String args[]) {
    Formatter fmt = new Formatter();
    fmt.format("0%g\n", 123.1);

  }
}
The output:
0123.100
answered May 5, 2014 by omari Sr Member (3,860 points)

Related questions

0 votes
1 answer 175 views
175 views asked Nov 3, 2011 by anonymous
0 votes
1 answer 17 views
0 votes
2 answers 15 views
15 views asked Jan 30, 2014 by john Guru (27,140 points)
0 votes
1 answer 80 views
80 views asked May 10, 2014 by augustaina Sr Member (4,820 points)
0 votes
1 answer 86 views
86 views asked May 10, 2014 by augustaina Sr Member (4,820 points)
...