| |
6. 6. 9. The # Flag |
|
The # flag can be applied to the %o, %x, %e, and %f format specifiers. |
For %e and %f, the # ensures that there will be a decimal point even if
there are no decimal digits. |
Preceding the %x specifier with a #, the hexadecimal number will be printed with a 0x prefix. |
Preceding the %o specifier with # causes the number to be printed with a leading zero. |
import java.util.Formatter;
public class MainClass {
public static void main(String args[]) {
Formatter fmt = new Formatter();
fmt.format("%#e", 1F);
System.out.println(fmt);
}
}
|
|
1.000000e+00 |
|