&& (AND) and || (OR) in Java IF statements
- by Azimuth
My question might be very basic but still I think it worths to ask. I have the following code:
if(!partialHits.get(req_nr).containsKey(z) || partialHits.get(req_nr).get(z) < tmpmap.get(z)){
partialHits.get(z).put(z, tmpmap.get(z));
}
where partialHits is a HashMap. What will happen if the first statement is true? Will Java still check the second statement? Because in order the first statement to be true, the HashMap should not contain the given key, so if the second statement is checked, I will get NullPointerException.
So in simple words, if we have the following code
if(a && b)
if(a || b)
would Java check b if a is false in the first case and if a is true in the second case?