You probably need to take the use case in account too:
If most of the time you expect numbers to be valid, then catching the exception is only causing a performance overhead when attempting to convert invalid numbers. Whereas calling some isInteger()
method and then convert using Integer.parseInt()
will always cause a performance overhead for valid numbers - the strings are parsed twice, once by the check and once by the conversion.