NumberFormatException is a subclass of Exception. Saying that both catch
blocks should have the same behavior is like saying that you don't have any special treatment for NumberFormatException
, just the same general treatment you have for Exception
. In that case, you can just omit its catch
block and only catch Exception
:
try {
int Id = Integer.parseInt(idstr);
TypeInfo tempTypeInfo = getTypeInfo(String.valueOf(Id));
updateTotalCount(tempTypeInfo);
} catch (Exception exception) {
exception.printStackTrace();
}