Why is “throws Exception” necessary when calling a function?

后端 未结 8 1786
借酒劲吻你
借酒劲吻你 2020-11-29 15:37
class throwseg1
{
    void show() throws Exception
    {
        throw new Exception(\"my.own.Exception\");
    }

    void show2() throws Exception  // Why throws i         


        
8条回答
  •  佛祖请我去吃肉
    2020-11-29 15:53

    If you propagate the exception by declaring the throws directive in the signature of the current method, then somewhere up the line or call stack a try/catch construct must be used to handle the exception.

提交回复
热议问题