•The NumberFormatException class is derived from the IllegalArgumentException class.
–this means that the
IllegalArgumentException class is more general than the
NumberFormatException
–try
–{
– number = Integer.parseInt(str);
–}
–catch
(IllegalArgumentException e)
–{
– System.out.println("Bad number
format.");
–}
–catch
(NumberFormatException e) // this is an ERROR because
the more specific exception follows the more general
exception.
–{
– System.out.println(str + " is not a
number.");
–}