How can I throw an exception for the whole class instead of doing it method by method

北慕城南 提交于 2019-11-28 10:49:15

Sorry, No. There is no way to do this in Java.

if you throw exception with class level then how you identify that on which type of exception is thrown by method... or on which method it throw exception.

so it is not allow in java...and also its not a good coding with java

You can by throw exception at constructor level. You can see how FileInputStream force us to throw IO exception while creating object of it.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!