Boolean(boolean boolValue); Boolean(String boolString);
| 方法 | 返回值 | 功能 |
|---|---|---|
| booleanValue() | boolean | 将 Boolean 对象的值以对应的 boolean 值返回 |
| equals(Object obj) | boolean |
判断调用该方法的对象与 obj 是否相等。当且仅当参数不是 null,且与调用该 方法的对象一样都表示同一个 boolean 值的 Boolean 对象时,才返回 true |
| parseBoolean(String s) | boolean | 将字符串参数解析为 boolean 值 |
| toString() | string | 返回表示该 boolean 值的 String 对象 |
| valueOf(String s) | boolean | 返回一个用指定的字符串表示的 boolean 值 |
public class Test05 {
public static void main(String[] args) {
Boolean b1 = new Boolean(true);
Boolean b2 = new Boolean("ok");
Boolean b3 = new Boolean("true");
System.out.println("b1 转换为 boolean 值是:" + b1);
System.out.println("b2 转换为 boolean 值是:" + b2);
System.out.println("b3 转换为 boolean 值是:" + b3);
}
}
程序非常简单,运行后的输出结果如下:
b1 转换为 boolean 值是:true b2 转换为 boolean 值是:false b3 转换为 boolean 值是:true
版权说明:Copyright © 广州松河信息科技有限公司 2005-2025 版权所有 粤ICP备16019765号
广州松河信息科技有限公司 版权所有