ouou
How to print different Messge for the same NumberFormatException on different cause objects in JAVA?
0 Answer(s)      4 years and 3 months ago
Posted in : Java Beginners

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"); } .

Advertisement
View Answers









Related Tutorials/Questions & Answers:
Advertisements