java - Will this if statement throw an exception or ignore it? -


this question has answer here:

will code not evaluate divide 0 portion of if statement since first part evaluates false? if so, true cases in java ides? or compilers throw exception?

int n = 0; int x = 5; if (n != 0 && x / n > 100) {     system.out.println(" s1"); } else {     system.out.println("s2"); } 

from jls §15.23:

the conditional-and operator && & (§15.22.2), evaluates right-hand operand if value of left-hand operand true.

so no, not exception.

obviously assumes have single-threaded or thread safe environment - if introduce visibility problems mix it's anyone's guess.


Comments

Popular posts from this blog

c++ - No viable overloaded operator for references a map -

java - Custom OutputStreamAppender not run: LOGBACK: No context given for <MYAPPENDER> -

java - Cannot secure connection using TLS -