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.
Exception when working with numbers
- 3
Locked
Comments (3)
- Popular
- New
- Old
You must be signed in to leave a comment
sgubow
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.
+1
Michael T Schaefer
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!
0
Michael T Schaefer
2 February 2021, 18:45
Ahh... "toString()"...
+1