Computer Applications
When do the numeric wrapper class constructors raise NumberFormatException ?
Java Library Classes
11 Likes
Answer
The numeric wrapper class constructors may raise NumberFormatException at the time of conversion of String arguments to primitive data types. The exception is raised when the String argument cannot be converted to the desired data type.
For example,
int val = Integer.parseInt("A");
Here, the String argument "A" cannot be converted to int type and therefore, NumberFormatException is thrown.
Answered By
8 Likes