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!
if mem.get(s) is null and will be compared with a primitive boolean value, java will make autoboxing. It means it will call null.booleanValue().
Thats why you get a NPE.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With