In javadoc, what is the difference between the tags @throws and @exception?

人走茶凉 提交于 2019-12-03 22:06:40

There is none, they're synonyms. From the docs:

Documenting Exceptions with @throws Tag
NOTE - The tags @throws and @exception are synonyms.

@throws was added because it is a keyword ("throws" clause in a method declaration),

and, as a verb, it is just more natural to read. This reads as a sentence:

@throws NullPointerException

while this seem more redundant:

@exception NullPointerException

Otherwise, both are synonyms

@exception isn't 100% correct if you code throws a Throwable. @throws is more exact. (I realize there isn't a good use case for ever using throw new Throwable(), but theoretically it is allowed.)

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