The output of this code
System.out.printf("%d %(d %+d %05d\n", 3, -3, 3, 3);
is
3 (3) +3 00003
can somebody please explain why the -3 is printed as 3 in this statement?
can somebody please explain why the -3 is printed as 3 in this statement?
Its isn't, it is being printed as (3)
From the Javadoc for Formatter say flag (
The result will enclose negative numbers in parentheses
The Formatter help says that the format "(" means it will enclose negative numbers in parentheses.
In bookkeeping, amounts owed are often represented by red numbers, or a number in parentheses, as an alternative notation to represent negative numbers.
From Wikipedia: Negative Numbers
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With