When to use throws in a Java method declaration?

后端 未结 7 1213
情话喂你
情话喂你 2020-12-07 14:10

So I thought I had a good basic understanding of exception-handling in Java, but I was recently reading some code that gave me some confusion and doubts. My main doubt that

相关标签:
7条回答
  • 2020-12-07 14:56

    In the example you gave, the method will never throw an IOException, therefore the declaration is wrong (but valid). My guess is that the original method threw the IOException, but it was then updated to handle the exception within but the declaration was not changed.

    0 讨论(0)
提交回复
热议问题