在javadoc中,标签@throws和@exception之间有什么区别? [英] In javadoc, what is the difference between the tags @throws and @exception?

查看:2522
本文介绍了在javadoc中,标签@throws和@exception之间有什么区别?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

采用以下基于数组的字符堆栈的实现,例如:

Take the following implementation of a array-based stack of chars for example:

public char peek() throws Underflow {
    if (!isEmpty()) {
        return stack[pos];
    } else {
        throw new Underflow("Peeking at an empty stack.");
    }
}

当我只使用文本编辑器时我回来了总是使用@exception标签,但现在我的IDE(Netbeans)在生成javadoc时使用了@throws。

Back when I'm using just a text editor I always use the @exception tag, but now my IDE (Netbeans) used @throws when generating the javadoc.

所以我的问题是,两者之间有什么区别什么时候应该优先于另一个(例如使用上面的代码)?

So my question is, what is the difference between the two and when should one be preferred over another (using the above code for example)?

推荐答案

没有,他们是同义词。 来自文档

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


使用记录例外@throws 标记

注意 - 标记 @throws @exception 是同义词。

这篇关于在javadoc中,标签@throws和@exception之间有什么区别?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆