我知道它非常简单的问题.但我想知道布尔运算符的stringformat.例如,下面显示了integer,string和float的字符串格式.什么可以为布尔运算符true/false?
System.out.printf("The value of the float " +
"variable is %f, while " +
"the value of the " +
"integer variable is %d, " +
"and the string is %s",
floatVar, intVar, stringVar);
Run Code Online (Sandbox Code Playgroud)
LMK*_*LMK 57
'b'或'B'general如果参数arg为null,则结果为"false".如果arg是布尔值或布尔值,则结果是String.valueOf(arg)返回的字符串.否则,结果为"true".java docs:http://docs.oracle.com/javase/7/docs/api/java/util/Formatter.html#syntax

Zhe*_*Hao 15
System.out.printf("boolean variable is %b",boolVar);
Run Code Online (Sandbox Code Playgroud)
Nin*_*ale 11
另一种方法是——
String output = String.format("boolean variable is %b",true);
System.out.print(output);
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
47676 次 |
| 最近记录: |