Java:Method返回自己的JavaDoc

时间:2014-06-04 12:03:25

标签: java javadoc

我想编写一个Java方法,将其自己的JavaDoc作为String返回。这可能吗?

例如:

class MyClass{

  /** This method explains itself in a great length and describes 
  the parameters for the   class. It is called whenever the parametrization 
  of that class (based on a config file) is incorrect to remind the user of 
  this class to fix it. */

  public String explain() {
      return "Here simply return the JavaDoc";
  }


 public boolean checkParams(){

    // check parameters
    // call explain if the check went wrong and return false
    // return true if everything went fine.       
 }
}

1 个答案:

答案 0 :(得分:2)

您不能这样做,因为它已从编译的代码中删除。您可以改为使用注释并编写注释处理器来读取它们。