How to print different Messge for the same NumberFormatException on different cause objects in JAVA?

Ads

 
 

Share on Google+Share on Google+

ouou
How to print different Messge for the same NumberFormatException on different cause objects in JAVA?
0 Answer(s)      6 years and 7 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"); } .

Ads
View Answers
Ads









Related Tutorials/Questions & Answers:
Advertisements

Ads

 
Advertisement null

Ads