boolean是基本数据类型
Boolean是它的封装类,和其他类一样,有属性有方法,可以new,例如:
Boolean bl= new Boolean("true"); // boolean 则不可以!
Boolean 是boolean 的实例化对象类,和Integer对应int一样
自jdk1.5.0以上版本后,Boolean在"赋值"和判断上和boolean一样,
即是你: boolean b1 = true ; 或者 Boolean b2 = true ; 都可以。
唯一只能使用Boolean上的就是从列表或者哈希表获取值时。
Map map = new ConcurrentHashMap(); boolean is_existed = false;//是否存在 boolean isDownloadFinished = false;//是否下载完 boolean isDownloadStarted = false;//是否被处理
然后
map.put("isDownloadStarted", price); map.put("is_existed", is_existed); map.put("isDownloadFinished", isDownloadFinished); return map;
在取出的时候
Boolean code_is_valid = (Boolean) map.get("is_existed");//前面只能用Boolean强制转换,不能使用boolean.