Search code examples
javamethodsjavadoc

Usage of @see in JavaDoc?


When do I use @see when dealing with JavaDocs? What is its usage?

For example if MethodA calls MethodB then do I have to put @see in MethodB's javadoc and reference MethodA because that is what called it, or do I have to put a reference to MethodB from MethodA because it's calling it. I've read the stuff about @see on the Oracle website and it seems to me to be incredibly vague, it says it means "see also" but not really what that means!


Solution

  • Yeah, it is quite vague.

    You should use it whenever it may be useful for readers of the documentation of your method to also look at some other method. If the documentation of your methodA says "Works like methodB but ...", then you surely should put a link.

    An alternative to @see would be the inline {@link ...} tag:

    /**
     * ...
     * Works like {@link #methodB}, but ...
     */
    

    When the fact that methodA calls methodB is an implementation detail and there is no real relation from the outside, you don't need a link here.