如何在 Java 中添加方法描述?我使用 NetBeans IDE。

您可以使用 javadocs 使用 /** 注释 */
对于一种方法,基本上你可以拥有
/**
The Desciption of the method to explain what the method does
@param the parameters used by the method
@return the value returned by the method
@throws what kind of exception does this method throw
*/
您可以使用此链接获取更多帮助http://www.oracle.com/technetwork/java/javase/documentation/index-137868.html#descriptions
使用 javadoc 注释 - /** 这是一条注释 */
检查此链接以获取详细文档http://en.wikipedia.org/wiki/Javadoc
在您的方法上方写评论应该做您想要的示例:
/**
This method does some serious stuff
*/
public int getN()
{
return n;
}
如果您使用 javadocs,它应该是方法的描述。
请参阅指南并查看一些标准 Java 类的源代码。
都在这里: http ://docs.oracle.com/javase/7/docs/technotes/guides/javadoc/index.html 。
我添加这句话是因为我上面的答案对于 SO 来说太短了。:-)
我想 IDE 正在寻找源文件中的 javadoc 定义。因此,您需要将源附加到项目中使用的库。
@Description("method name")
methodName<String> getset(){...}
@Description("class name")
class ClassName{..}