Should methods that throw RuntimeException indicate it in method signature?

后端 未结 7 1694
小鲜肉
小鲜肉 2020-11-30 23:43

For example, many methods in frameworks/JDK might throw

java.lang.SecurityException 

but this is not indicated in the method signature (si

7条回答
  •  独厮守ぢ
    2020-11-30 23:50

    If you are writing an api for use by others, then there is ample reason for explicit documentation of your intent in the api and there is no downside to declaring RuntimeExceptions in the method signature.

提交回复
热议问题