Suppose I have the following expression
String myString = getStringFromSomeExternalSource();
if (myString != null && myString.trim().length() != 0) {
...
}
Eclipse warns me that myString
might be null in the second phrase of the boolean expression. However, I know some that some compilers will exit the boolean expression entirely if the first condition fails. Is this true with Java? Or is the order of evaluation not guaranteed?
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…