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.
(其中partialHits
是一个HashMap。)
What will happen if the first statement is true?
(如果第一个陈述为真会怎样?)
Will Java still check the second statement? (Java还会检查第二条语句吗?)
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
. (因为为了使第一条语句为真,所以HashMap不应包含给定的键,因此,如果选中第二条语句,则将获得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?
(Java是否会在第一种情况下检查b
如果a
为假,而在第二种情况下a
为true?)
ask by Azimuth translate from so 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…