Difference between try-catch and throw in java

前端 未结 8 445
佛祖请我去吃肉
佛祖请我去吃肉 2020-12-07 10:02

What is the difference between try-catch and throw clause. When to use these?

Please let me know .

8条回答
  •  不思量自难忘°
    2020-12-07 10:37

    throws is a declaration that declares multiple exceptions that may occur but do not necessarily occur, throw is an action that can throw only one exception, typically a non-runtime exception, try catch is a block that catches exceptions that can be handled when an exception occurs in a method,this exception can be thrown.An exception can be understood as a responsibility that should be taken care of by the behavior that caused the exception, rather than by its upper callers.

提交回复
热议问题