title: java performance : Is storing a hashMap value in a variable redundant?
body: <p>my goal is to reduce memory usage.
  should I store a hashMap value in a variable if I need to use that value multiple times?</p>
  
  <pre><code>public void upcCheck() {
            String prodUPC = pHashMap.get("productUpc");
            if(prodUpc == ''){
              //do stuff;
            }
            else if(prodUpc == '0123456'){
              //do other stuff;
            }
      }
  </code></pre>
  
  <p>Or should I just always use the hashMap's get() method to avoid redundancy and unecessary memory usage?</p>
  
  <pre><code> public void upcCheck() {
  
                if(pHashMap.get("productUpc") == ''){
                  //do stuff;
                }
                else if(pHashMap.get("productUpc") == '0123456'){
                  //do other stuff;
                }
          }
  </code></pre>
  
  <p>The hashMap contains alot of values ae: product type, product price etc... Many methods are set to work with those values. So I was wondering about the best approach.
  Thank you!</p>