正确用法:boolean repeatIndicator = Boolean.valueOf("true").booleanValue();
或者也可以使用Boolean.parseBoolean()方法,但此方法是jdk1.5以后推出的。

以下是Boolean.getBoolean的正确用法:

public class TestGetBoolean
{

public static void main(String[] args){

//大写的true返回为false,必须是小写的true
String s1 = "true";

String s2 = new String("true");

//这里将s1存放到Java系统属性中了.
System.setProperty(s1,"true");

System.setProperty(s2,"true");

//这里从系统属性中获取s1,所以获取到了。
System.out.println(Boolean.getBoolean(s1));//true

System.out.println(Boolean.getBoolean(s2));//true

String s3 = "true";

//很明显s3并没有存放到系统属性中所以返回false。
System.out.println(Boolean.getBoolean(s3));//false

//这个更是错的了,呵呵。
System.out.println(Boolean.getBoolean("true"));//false
}

}

Boolean.parseBoolean("true") 和 Boolean.getBoolean("true");的区别及用法的更多相关文章

  1. true && number !== boolean

    true && number !== boolean bug let result = ``; // section, name ? create text, compute cent ...

  2. freemark标签从后台接过来数据Boolean在前台还是Boolean输出(四)

    FREEMARK标签中输出BOOLEAN值 private boolean showHeader=true; public boolean getShowHeader(){ return this.s ...

  3. request.getSession(true)和request.getSession(false)的区别

    request.getSession(true)和request.getSession(false)的区别   request.getSession(true):若存在会话则返回该会话,否则新建一个会 ...

  4. ReLU(inplace=True),这里的inplace=true的意思

    ReLU(inplace=True),这里的inplace=true的意思 待办 inplace=True means that it will modify the input directly, ...

  5. 转:request.getSession(true)和request.getSession(false)的区别

    1.转自:http://wenda.so.com/q/1366414933061950?src=150 概括: request.getSession(true):若存在会话则返回该会话,否则新建一个会 ...

  6. javascript中的return、return true、return false、continue区别

    1.语法为:return 表达式; 2.w3c中的解释: 语句结束函数执行,返回调用函数,而且把表达式的值作为函数的结果  也就是:当代码执行到return语句时,函数返回一个结果就结束运行了,ret ...

  7. jquery prop('checked', true)解决attr('checked', true)不能选中radio问题

    正如标题所言,使用:prop('checked', true)就可以了

  8. @RequestParam(required = true),@RequestParam(required = true)

    今天在页面请求后台的时候遇到了一个问题,请求不到后台 页面代码 <li>                        <a href="javascript:void(0 ...

  9. Spark2.1.0——内置RPC框架详解

    Spark2.1.0——内置RPC框架详解 在Spark中很多地方都涉及网络通信,比如Spark各个组件间的消息互通.用户文件与Jar包的上传.节点间的Shuffle过程.Block数据的复制与备份等 ...

随机推荐

  1. 学习练习 java 小题

    Scanner a = new Scanner(System.in); System.out.println("请输入您的分数"); int fen = a.nextInt(); ...

  2. oracle 闪回技术

    oracle默认不启动闪回数据库 如果需要启动闪回数据库,数据库需要设置为归档模式,并启用恢复区. 1.查看是否启动闪回删除 SQL> show parameter recyclebin; NA ...

  3. No.004 Median of Two Sorted Arrays

    4. Median of Two Sorted Arrays Total Accepted: 104147 Total Submissions: 539044 Difficulty: Hard The ...

  4. Find out who the “mole” is?

    Blueheat Company’s  production server was out of order again. The CEO was very upset and want their ...

  5. 解决win 7&win xp等系统无法正常用U盘安装或启动

    目前,制作启动U盘通常是用ultraiso,但由于各种硬件设备与系统的更新,导致现在装系统会出现各种错误. 在用ultraiso制作的启动U盘,装XP时,可能找不到引导项:装win7时,可能提示”wi ...

  6. 【好文要转】Python:模拟登录以获取新浪微博OAuth的code参数值

    [转自]http://www.tuicool.com/articles/zAz6zi [原文]http://blog.segmentfault.com/hongfei/1190000000343851 ...

  7. C/C++下Netbeans的配置

    目录 目录1 1 netbeans开发环境搭建2 2 netbeans工程管理2 2.1 采用IDE自动生成Makefile2 3 netbeans工程配置2 3.1 编译工具链3 3.1.1 添加配 ...

  8. DirectDraw打造极速图形引擎(Alpha混合)

    显然DirectDraw是Windows下写2D图形程序的最好选择,虽然Direct3D也可以写,但是没DirectDraw简单方便,特别对于初学者,一来就接触那么多函数和参数总不是件愉快的事,所以我 ...

  9. 模拟cpu调度

    先来先服务实现简单但是平均周转时间过长 短作业优先算法缩短了平均周转时间 #!/usr/bin/python #-*- coding: utf-8 -*- # # table # 0:进程号 1:到达 ...

  10. linu流量监控

    iftophttp://www.cnblogs.com/ggjucheng/archive/2013/01/13/2858923.html 默认是监控第一块网卡的流量iftop 监控eth1iftop ...