84 字
1 分钟
java经验
2018-01-23

java 经验

what different between Boolean.TRUE and true

参考链接

[What the difference between Boolean.TRUE and true](https://stackoverflow.com/questions/31775618/what-the-difference-between-boolean-true-and-true)

说明

> [](https://stackoverflow.com/posts/31775618/timeline) > > Firstly, I have >
private Map<String, Boolean> mem = new HashMap<String, Boolean>();

And then:

if (wordDict.contains(s) || Boolean.TRUE==mem.get(s)) {
return true;
}

why can’t I use “mem.get(s)==true” in the if statement. There will be a error “Line 6: java.lang.NullPointerException”

I think I still cannot understant wrapper class well. Please give me some guidance. Thank you!

java经验
https://iszengmh.pages.dev/posts/java经验/
作者
Rise Zeng
发布于
2018-01-23
许可协议
CC BY-NC-SA 4.0