Formatting using printf and format

后端 未结 3 1663
走了就别回头了
走了就别回头了 2020-12-16 09:40

In the following program

class ZiggyTest2 {

    public static void main(String[] args){     

        double x = 123.456;
        char c = 65;
        int i         


        
相关标签:
3条回答
  • 2020-12-16 10:06

    for "%b" : If the argument arg is null, then the result is "false". If arg is a boolean or Boolean, then the result is the string returned by String.valueOf(). Otherwise, the result is "true".

    reference

    0 讨论(0)
  • 2020-12-16 10:18

    Because the value is of type double and this is how the %b converter works with values of this type.

    0 讨论(0)
  • 2020-12-16 10:19

    The API documentation seems to clearly state why.

    If the argument arg is null, then the result is "false". If arg is a boolean or Boolean, then the result is the string returned by String.valueOf(). Otherwise, the result is "true".

    0 讨论(0)
提交回复
热议问题