Exception when working with numbers

  • 3
  • Locked
Esteemed colleagues, things are getting serious. We're starting sting operation to catch exceptions. The secret CodeGym center has sent the following task, and I quote: "Catch (and display the type of) the exception that occurs when the following code is executed: int a = 42 / 0;". Note: Complete this task immediately.
You can't complete this task, because you're not signed in.
Comments (3)
  • Popular
  • New
  • Old
You must be signed in to leave a comment
sgubow
Level 10 , Forest Grove, United States
7 May 2021, 16:32
Hint: run the code one time and it will tell you what type of error you need to account for.
Michael T Schaefer
Level 15 , Columbia, United States
2 February 2021, 17:51
I'm not fulfilling the objective, "The displayed message must contain the type of exception that occurred." I can't imagine any other way this should be done than by calling getMessage() on the Arithmetic Exception reference in my catch code block. All other objectives are checked green when I verify. Thanks to anyone out there!
Michael T Schaefer
Level 15 , Columbia, United States
2 February 2021, 18:45
Ahh... "toString()"...