• Dear Guest, Please do NOT forget to join our JAVA JOBS (ONLY) FACEBOOK GROUP to be aware of latest JAVA openings, and you may also post any JAVA related queries/jobs.

What is NumberFormatException ?

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.
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.