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
111 views
asked 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 by omari Sr Member (3,860 points)

Related questions

0 votes
1 answer 181 views
181 views asked by anonymous
0 votes
2 answers 15 views
15 views asked by john Guru (27,140 points)
0 votes
1 answer 85 views
85 views asked by augustaina Sr Member (4,820 points)
0 votes
1 answer 93 views
...