Can I use throws in constructor?

前端 未结 12 2232
迷失自我
迷失自我 2021-01-13 21:03

I have to initialize file objects inside the constructor and for handling the exception, is it efficient using throws or should I go for try/

12条回答
  •  春和景丽
    2021-01-13 21:38

    I'd go with 'throws' if you care about what is initialized in the constructor, which I guess you do.

    If you hide the exceptions, then that will probably cause problems later on.

提交回复
热议问题