What is NumberFormatException ?

#2
What is NumberFormatException? If possible provide me with an example. Regards, Naveen.
Hi Naveen,

When we are converting a String value into int type then we can get NumberFormatException, if the String contains a non-integer number.

Example :

String s = "abc" ;
int num = Integer.parseInt(s);

- In the above example the String s contains the non-integer number (i.e. "abc"), and we are trying it to convert into integer type, at that time JVM will throw NumberFormatException.
 
#4
A NumberFormatException is an Exception that may be tossed when you endeavor to change over a String into a number, where that number may be an int , a buoy , or some other Java numeric sort.
 
Top