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

后端 未结 8 1788
借酒劲吻你
借酒劲吻你 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:43

    Basically, if you are not handling the exception in the same place as you are throwing it, then you can use "throws exception" at the definition of the function.

提交回复
热议问题