【发布时间】:2016-11-12 02:01:28
【问题描述】:
if 语句如何将Boolean 对象识别为boolean?如:
Boolean b = new Boolean(true);
if(b){
System.out.println("true!");
} else {
System.out.println("false!");
}
这将打印为 true,但如何识别 Boolean?
【问题讨论】:
-
顺便说一句,如果您不希望该值为空,您应该尽可能使用原语而不是包装器。