StringFormat for Java布尔运算符 [英] StringFormat for Java Boolean Operator
问题描述
我知道它非常简单的问题。但我想知道布尔运算符的stringformat。
例如,下面显示了整数,字符串和浮点数的字符串格式。什么可以为布尔运算符true / false?
I know its very simple question. but I would like to know the stringformat for boolean operator. For example, below shows the string formats for integer, string and float. what could be for boolean operator 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);
推荐答案
'b'或'B'一般如果参数arg为null,结果为false。如果arg是布尔值或布尔值,则结果是String.valueOf(arg)返回的字符串。否则,结果为true。
java docs: http:// docs.oracle.com/javase/7/docs/api/java/util/Formatter.html#syntax
'b' or 'B' general 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". java docs : http://docs.oracle.com/javase/7/docs/api/java/util/Formatter.html#syntax
这篇关于StringFormat for Java布尔运算符的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!