How to print different Messge for the same NumberFormatException on different cause objects in JAVA?
try { int a=Integer.parseInt(aStr); int b= Integer.parseInt(bStr); }catch (NumberFormatException ex) { if ex's cause is from int a;//ex.getCause()=a? System.out.println("a is not a integer"); if ex's cause is from int b System.out.println("b is not a integer"); }
or 2 catch block, but how to complete it?
try { int a=Integer.parseInt(aStr); int b= Integer.parseInt(bStr); }catch (NumberFormatException ex) { if ex's cause is from int a;//ex.getCause()=a? System.out.println("a is not a integer");} catch (NumberFormatException ex){ if ex's cause is from int b System.out.println("b is not a integer"); } .
Ads