首页 > 文档 > boolean()布尔转换
2017
07-20

boolean()布尔转换

Name

boolean()布尔转换

   

Examples

String s = “true”;

boolean b = boolean(s);

if (b) {

println(“The boolean is true”);

} else {

println(“The boolean is false”);

}

Description

Converts an int or String to its boolean representation. For an int, any non-zero value (positive or negative) evaluates to true, while zero evaluates to false. For a String, the value “true” evaluates to true, while any other value (including “false” or “hippopotamus”) evaluates to false.

When an array of int or String values is passed in, then a boolean array of the same length is returned.

int 或字符串转换为其布尔表示形式。对于 int, 任何非零值 (正值或负数) 的计算结果为 true, 而零计算为 false。对于字符串, “true” 计算为 true, 而任何其他值 (包括 “false” 河马“) 的计算结果为 false

 

在传入 int 或字符串值的数组时, 返回相同长度的布尔数组。



最后编辑:
作者:卡萨布兰卡
这个作者貌似有点懒,什么都没有留下。

留下一个回复

你的email不会被公开。