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?
public void upcCheck() {
String prodUPC = pHashMap.get("productUpc");
if(prodUpc == ''){
//do stuff;
}
else if(prodUpc == '0123456'){
//do other stuff;
}
}
Or should I just always use the hashMap's get() method to avoid redundancy and unecessary memory usage?
public void upcCheck() {
if(pHashMap.get("productUpc") == ''){
//do stuff;
}
else if(pHashMap.get("productUpc") == '0123456'){
//do other stuff;
}
}
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!