Why do Double.parseDouble(null) and Integer.parseInt(null) throw different exceptions?
Is this a historical accident or intentional? The documentation clearly states two types of exceptions for Double.parseDouble(...)
and one for Integer.parseInt()
, but it seems inconsistent:
Integer.parseInt(null); // throws java.lang.NumberFormatException: null
However
Double.parseDouble(null); // throws java.lang.NullPointerException
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…