String a = null;
String b = null;
try {
a.equals(b.toString());
} catch (Exception e) {
e.printStackTrace();
}
我知道会抛出一个NPE,但我想知道它是否会在a.equals()
之前被b.toString()
抛出叫什么?
最佳答案
是的,方法调用表达式中的参数在方法调用本身之前计算。因此 B.toString()
将会引发异常。
关于参数中的 Java NullPointerException,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/28844738/