printf的问题

xiazdong 2013-08-20 10:48:49

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。

请大神帮忙!
...全文
259 4 打赏 收藏 转发到动态 举报
写回复
用AI写文章
4 条回复
切换为时间正序
请发表友善的回复…
发表回复
Mourinho 2013-08-22
  • 打赏
  • 举报
回复
valenon 2013-08-21
  • 打赏
  • 举报
回复
引用 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
杨春华 2013-08-21
  • 打赏
  • 举报
回复
huntor 2013-08-20
  • 打赏
  • 举报
回复
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

62,621

社区成员

发帖
与我相关
我的任务
社区描述
Java 2 Standard Edition
社区管理员
  • Java SE
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧