Mia*_*mad 49 java syntax comments javadoc
以下陈述是什么意思?
/* (non-Javadoc)
*
* Standard class loader method to load a class and resolve it.
*
* @see java.lang.ClassLoader#loadClass(java.lang.String)
*/
@SuppressWarnings("unchecked")
Run Code Online (Sandbox Code Playgroud)
DwB*_*DwB 28
Javadoc查找以/ **开头的注释.按照惯例,不打算成为java文档一部分的方法注释以"/*(非Javadoc)"开头(至少当您的开发环境是Eclipse时).
顺便说一句,避免在方法中使用多行注释.例如,避免这样:
public void iterateEdges()
{
int i = 0;
/*
* Repeat once for every side of the polygon.
*/
while (i < 4)
{
}
}
Run Code Online (Sandbox Code Playgroud)
以下是首选:
public void iterateEdges()
{
int i = 0;
// Repeat once for every side of the polygon.
while (i < 4)
{
++i;
}
}
Run Code Online (Sandbox Code Playgroud)
原因是你有可能注释掉整个方法:
/*
public void iterateEdges()
{
int i = 0;
// Repeat once for every side of the polygon.
while (i < 4)
{
++i;
}
}
*/
public void iterateEdges()
{
// For each square edge.
for (int index = 0; index < 4; ++index)
{
}
}
Run Code Online (Sandbox Code Playgroud)
现在,您仍然可以在实现新方法时看到旧方法的行为.这在调试时也很有用(为了简化代码).
Tho*_*sen 26
我看到Eclipse生成的这条消息,当程序员要求Eclipse将Javadoc注释添加到[编辑:Eclipse认为] Javadoc工具实际上不会使用它的位置的某些代码时.
一个常见的例子是在类实现的接口中实现一个方法(在Java 6中需要@Override注释).Javadoc将使用放在INTERFACE中的方法上的javadoc ,而不是实现中提供的方法.
评论的其余部分很可能是由一个不知道这一点的人写的.
Zoo*_*oot 12
/*
* This is the typical structure of a multi-line Java comment.
*/
/**
* This is the typical structure of a multi-line JavaDoc comment.
* Note how this one starts with /**
*/
Run Code Online (Sandbox Code Playgroud)