Can I use multiple @throws tags for the same excep

2019-06-20 05:39发布

Can I use multiple @throws javadoc tags if my application throws the same exception for multiple reasons? For example:

@throws UserException if issue 1 happened
@throws UserException if issue 2 happened
@throws UserException if issue 3 happened

Is it prohibited by JavaDoc standard?

2条回答
啃猪蹄的小仙女
2楼-- · 2019-06-20 06:15

It is valid in java 6,7 and 8. See the docs:

Multiple @throws tags can be used in a given doc comment for the same or different exceptions.

(emph. mine)

查看更多
时光不老,我们不散
3楼-- · 2019-06-20 06:19

Just tested this the generated JavaDoc contains all 3 @throws.

查看更多
登录 后发表回答