Throw multiple exceptions at the same time. | Sololearn: Learn to code for FREE!
Nouvelle formation ! Tous les codeurs devraient apprendre l'IA générative !
Essayez une leçon gratuite
+ 26

Throw multiple exceptions at the same time.

Is it possible to throw multiple exceptions at the same time in Java? maybe a work around the language features?

21st May 2018, 11:18 AM
Amir - avatar
5 Réponses
+ 24
Ulisses Cruz : I want to invoke a combination of different exception handlers at the same time... maybe it can be achieved by Events. ūü§Ēūü§Ē yeah I can implement a similar behaviour using Events I think
21st May 2018, 12:09 PM
Amir - avatar
+ 4
Yes. You can throw an ARRAY out of Bounds exception, a .io* Exception, and others. Have done so. Such cluttered console! :)
22nd May 2018, 1:31 AM
Apple Blossom
Apple Blossom - avatar
+ 1
I don't think it is possible. Why would you do that?
21st May 2018, 11:21 AM
Ulisses Cruz
Ulisses Cruz - avatar
+ 1
I advise you to use events so, throwing exceptions is expensive (slow) to be used with purpose. Exceptions should really be thrown, when something goes wrong (unexpected event or illegal state). I would say avoid exceptions where you can. Building some application mechanics which is controlled by (expects) throwables is not a good idea. First it may seem handy and fast, but it is quite the opposite.
23rd May 2018, 3:10 PM
Magyar D√°vid
Magyar D√°vid - avatar
+ 1
processing exception runtime does something known as stack unwind, which may finish in Os, what known as program failure. you can re throw something on this way, but you can not enter this special mode twice
23rd Aug 2018, 7:42 PM
–ź—Ä—Ā–Ķ–Ĺ–ł–Ļ –ß–Ķ–Ī–ĺ—ā–į—Ä—Ď–≤
–ź—Ä—Ā–Ķ–Ĺ–ł–Ļ –ß–Ķ–Ī–ĺ—ā–į—Ä—Ď–≤ - avatar