What is a Java NumberFormatException?
Java exception FAQ: What is a Java NumberFormatException?
Answer: A Java NumberFormatException
usually occurs when you try to do something like convert a String
to a numeric value, like an int, float, double, long, etc.
The best way to show a NumberFormatException is by example, so here’s an example where I intentionally write bad Java code to throw a NumberFormatException
: