뭐해먹고 살지

Integer.valueOf(null) 의 Exception은? 본문

Computer Science/Java

Integer.valueOf(null) 의 Exception은?

알 수 없는 사용자 2012. 7. 18. 14:18

Integer.valueOf(null)의 Exception 은 NullPointerException 일까 NumberFormatException 일까?



Test Code


@Test

public void test() {

class A {

String n;

}


A a = new A();

a.n = null;


try {

Integer.valueOf(a.n);

} catch (Exception e) {

e.printStackTrace();

}

}



결과는..

java.lang.NumberFormatException: null



끝!