当前位置:编程学习 > JAVA >>

printf的问题


public class Printf01
{
public static void main(String[] args) {
System.out.printf("%f,%b",Math.PI,Math.E); //输出:3.141593,true
}
}


请问:第二个参数是 %b,应该接受boolean值,为什么接受了 Math.E 能够编译,并且输出 true。

请大神帮忙! --------------------编程问答--------------------  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(arg). Otherwise, the result is "true". 

source : Formatter javadoc --------------------编程问答--------------------
引用 1 楼 huntor 的回复:
 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(arg). Otherwise, the result is "true". 

source : Formatter javadoc
--------------------编程问答-------------------- --------------------编程问答--------------------
补充:Java ,  Java SE
CopyRight © 2012 站长网 编程知识问答 www.zzzyk.com All Rights Reserved
部份技术文章来自网络,