Boolean.parseBoolean("true") 和 Boolean.getBoolean("true");的区别及用法
正确用法: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");的区别及用法的更多相关文章
- true && number !== boolean
true && number !== boolean bug let result = ``; // section, name ? create text, compute cent ...
- freemark标签从后台接过来数据Boolean在前台还是Boolean输出(四)
FREEMARK标签中输出BOOLEAN值 private boolean showHeader=true; public boolean getShowHeader(){ return this.s ...
- request.getSession(true)和request.getSession(false)的区别
request.getSession(true)和request.getSession(false)的区别 request.getSession(true):若存在会话则返回该会话,否则新建一个会 ...
- ReLU(inplace=True),这里的inplace=true的意思
ReLU(inplace=True),这里的inplace=true的意思 待办 inplace=True means that it will modify the input directly, ...
- 转:request.getSession(true)和request.getSession(false)的区别
1.转自:http://wenda.so.com/q/1366414933061950?src=150 概括: request.getSession(true):若存在会话则返回该会话,否则新建一个会 ...
- javascript中的return、return true、return false、continue区别
1.语法为:return 表达式; 2.w3c中的解释: 语句结束函数执行,返回调用函数,而且把表达式的值作为函数的结果 也就是:当代码执行到return语句时,函数返回一个结果就结束运行了,ret ...
- jquery prop('checked', true)解决attr('checked', true)不能选中radio问题
正如标题所言,使用:prop('checked', true)就可以了
- @RequestParam(required = true),@RequestParam(required = true)
今天在页面请求后台的时候遇到了一个问题,请求不到后台 页面代码 <li> <a href="javascript:void(0 ...
- Spark2.1.0——内置RPC框架详解
Spark2.1.0——内置RPC框架详解 在Spark中很多地方都涉及网络通信,比如Spark各个组件间的消息互通.用户文件与Jar包的上传.节点间的Shuffle过程.Block数据的复制与备份等 ...
随机推荐
- [linux]查看文件编码和编码转换
方法一:file filename 方法二:在Vim中可以直接查看文件编码 :set fileencoding 即可显示文件编码格式. 如果你只是想查看其它编码格式的文件或者想解决用Vim查看文件乱码 ...
- button的type属性
今天为看懂一段js代码纠结了很久,搞不明白数据是如何实现post,因为button没有规定属性,其次对submit事件没太搞明白.忽然想起默认属性这个概念,豁然开朗,啊~ 1.请始终为按钮规定 typ ...
- idea 文件名乱码问题的解决
参考:http://www.cnblogs.com/xingma0910/p/4651889.html idea:文件名乱码:
- CSS实用的代码段
摘抄的一些代码还有自己总结的常用的代码~ 1>浏览器样式统一 *{ margin:0px; padding:0px; } 浏览器样式统一 2>清除浮动的方法 3>跨浏览器设置透明度 ...
- C#导出
#region DataReader 的数据导出到Excle 中 //public string Exports(string str_sql) //{ / ...
- 现代福尔摩斯 - Oxygen Forensic Suite
各位可曾听说过智能手机取证软件Oxygen Forensic Suite,它的logo是名侦探福尔摩斯一手抽着他的招牌雪茄,一手拿着放大镜,全神贯注地正进行调查工作. 使用过它的取证人员必定会对它的提 ...
- 深入理解JavaScript系列(转自汤姆大叔)
深入理解JavaScript系列文章,包括了原创,翻译,转载,整理等各类型文章,如果对你有用,请推荐支持一把,给大叔写作的动力. 深入理解JavaScript系列(1):编写高质量JavaScript ...
- 九度OJ 1544 数字序列区间最小值
题目地址:http://ac.jobdu.com/problem.php?pid=1544 题目描述: 给定一个数字序列,查询任意给定区间内数字的最小值. 输入: 输入包含多组测试用例,每组测试用例的 ...
- 自动发送EMAIL
*&---------------------------------------------------------------------* *& Report ZPP_SEND ...
- Web前端代码规范与页面布局
一. 规范目的: 为提高工作效率,便于后台人员添加功能及前端后期优化维护,输出高质量的文档,在网站建设中,使结构更加清晰,代码简明有序,有一个更好的前端架构,有利于SEO优化. 二. ...