Java中布尔的字符串表示形式
要获取布尔值的字符串表示形式,请使用toString()方法。
首先,我们valueOf()对布尔对象使用了该方法,并设置了一个字符串值。
Boolean val = Boolean.valueOf("false");然后使用“toString()”方法表示相同的内容。
val.toString();
让我们看看完整的示例,该示例在Java中打印布尔值(True和False)的字符串表示形式。
示例
public class Demo {
public static void main(String[] args) {
//假
Boolean val = Boolean.valueOf("false");
System.out.println("Displaying the string representation of Boolean");
System.out.println(val.toString());
//正确
val = Boolean.valueOf("true");
System.out.println(val.toString());
}
}输出结果
Displaying the string representation of Boolean false true
热门推荐
10 新年门口花束祝福语简短
11 盘锦结婚祝福语大全简短
12 父母生日祝福语 简短独特
13 家庭恩爱祝福语简短英文
14 高考俄语祝福语大全简短
15 虎年祝福语 诗句唯美简短
16 生日婚礼祝福语简短精辟
17 虎年喝酒拜年祝福语简短
18 教师闺蜜祝福语简短