简体   繁体   中英

Java: Method returns its own JavaDoc

I would like to write a Java method that returns its own JavaDoc as a String. Is this possible?

eg:

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.       
 }
}

You can't do that since it is removed from the compiled code. You might use annotations instead and write an annotation processor to read them.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM