Search code examples
javajavadocoverloading

Is it possible to get the same doc for overloaded methods?


I'm searching the best way to make documentations with overloaded methods.

I have two methods:

/**
* does something
* @param A
* @return result
*/
public String methodA(Type1 A);

/**
 * does something
 * @param A
* @return result
*/
public String methodA(Type2 A);

Since both methods render the same thing, is it possible to centralize the doc on a method which would take Object arguments? Or is there a better way to do so?


Solution

  • I think that your original intention to write a kind of "generic" documentation does not work out of the box. You need to take care of the parameters and the return value at least.

    Or is there a better way to do so ?

    To avoid redundancy of the actual documentation, you can use the @link tag.

    This is especially useful if the method requires a lot of documentation, like for example the Properties.load() methods.