title: Java: Logical operation of boolean with null
body: <p>Lets say I have a hash map like this:</p>
  
  <pre><code>private Map&lt;someObject, Boolean&gt; hashMap = new HashMap&lt;&gt;();
  </code></pre>
  
  <p>And I have two methods like this:</p>
  
  <pre><code>public void methodOne(key) {
      if (hashMap.get(key) == null || !hashMap.get(key)) {
         //do something
         hashMap.put(key, true);
      }
  }
  </code></pre>
  
  <p>and </p>
  
  <pre><code>public void methodtwo(key) {
      if (hashMap.get(key) != null &amp;&amp; hashMap.get(key)) {
         //do something else
         hashMap.put(key, false);
      }
  }
  </code></pre>
  
  <p>My code seems to be working, but I am wondering the logical operation that I am doing in the if statements are valid and wether there is a better way to do it?</p>
  
  <p>The other thing I am wondering is, what would be the result for the following logical operations:</p>
  
  <ul>
  <li><code>null || true</code></li>
  <li><code>null || false</code></li>
  <li><code>null &amp;&amp; true</code></li>
  <li><code>null &amp;&amp; false</code></li>
  </ul>