Performance cost of coding “exception driven development” in Java?

前端 未结 14 1696
生来不讨喜
生来不讨喜 2020-12-09 10:28

Are there are any performance cost by creating, throwing and catching exceptions in Java?

I am planing to add \'exception driven development\' into a larger project.

14条回答
  •  难免孤独
    2020-12-09 11:06

    There is a performance penalty to throwing an exception, but that's usually acceptable because the exception handling code only executes in exceptional cases. If you start using exceptions for flow control, you're turning the usual case around and making them expected behavior. I'd strongly recommend against it.

提交回复
热议问题