返回NumberFormatException时出现NullPointerException

时间:2017-04-19 07:40:10

标签: java string exception nullpointerexception null

此代码段:

public class NumberFormatException extends IllegalArgumentException {

public NumberFormatException (String test) {
super (test);
}

static NumberFormatException forInputString(String test) {
    return new NumberFormatException("Caused By: \"" + test + "\"");
}
}

抛出NullPointerException:

java.lang.NullPointerException

at java.lang.NumberFormatException.forInputString(NumberFormatException.java)

我无法确定'test'的哪个值可能是NullPointerException的根本原因,因为在串联中,如果String的值为null,则在屏幕上打印null。

0 个答案:

没有答案