Javadoc for local variables?

stefan.at.wpf picture stefan.at.wpf · May 12, 2012 · Viewed 9k times · Source

Short question: Is it possible to create Javadoc for local variables? (I just want an explanation for my local variable when hovering over it in Eclipse) Thanks for any hint :-)

Answer

Elist picture Elist · Mar 9, 2015

It can be done using Annotations.

Create a simple annotation type such as the following:

@Retention(RetentionPolicy.SOURCE)
@Target(ElementType.LOCAL_VARIABLE)
@interface LocalVariableDocumentation {
    String value();
}

And use it on your local variable:

@LocalVariableDocumentation("A very important object!")
Object anImportantObject;

Eclipse will show the annotation in the tooltip.