Eclipse 方法信息创建

Eclipse Method Information Creation

Visual Example of what I wish to accomplish.

在 Eclipse IDE 上用 java 语言创建方法时,如何创建它才能获得有关方法(白色)的信息(黄色)?

有时我会忘记我的方法的确切含义,最好保留我的评论。

(这应该不用说了,但是当我在其他文件中调用我的方法时,我想要描述。)

更多信息::

FileA.java{
 classA{
   classA(){}
   //Generic comment
   MethodA(){}
 }
}

FileB.java{
  MehtodB(){
    classA a = new classA();
    a.mehtodA(); ----->I should see //Generic comment when typing in this
  }
}

这就是所谓的'javadoc'。看起来是这样的:

/**
 * This is javadoc.
 * Note the double star start.
 *
 * You can {@code place some} tags in here for formatting.
 *
 * @param name User's full name, in title case, as they prefer to be called.
 * @throws IllegalArgumentException If name is blank
 */
public void setName(String name) {
 ...
}

'javadoc tutorial' 是网上搜索的好东西,大概:)

请注意,javadoc 未存储在 class 个文件中;它是单独存储的。如果你使用例如maven 来分发依赖项,您可以发送一个单独的 jar,其中包含 javadoc,javadoc 工具可以为您制作 HTML(但 eclipse 和 co 不需要这个)。通常,您 link javadoc(maven 会为您完成此操作,否则,右键单击依赖项,您可以关联一个源 jar 或 javadoc jar),或者如果它是源文件,eclipse 会自行解决。

希望我答对了你的问题。我认为您需要的是 'documentation comment' ,这是您在方法上方添加的一种注释。例如:

/** 
 * The add() method returns addition of given numbers.
 */  
public static int add(int a, int b){
     return a+b;
}  

当您浏览此方法时,系统会提示您评论。