0
public static class cls{
    private String text;
    public String getText(){
        return text;
    }
}

Is it possible to show the text variable in the docstrings of of cls in Java without having to copypaste the content?

AnthonyWJones
  • 187,081
  • 35
  • 232
  • 306
Christian
  • 25,249
  • 40
  • 134
  • 225

1 Answers1

1

I'm not sure what you are trying to do. You could link to the variable from your JavaDoc using on of these two ways:

/**
 * The cls class
 * see {@link cls#text} or
 * @see cls#text
 */
public static class cls {
    private String text;
...

You could then attach a JavaDoc to this variable and describe there what you need to say. To my knowledge there is no way to just display a line of code inside the JavaDoc other than copy and paste. But you can improve the formatting with HTML, if you like:

/**
 * The cls class, see this field:
 * <code>private String text;</code>
 */
public static class cls {
    private String text;
...

Hope that helps, but the question remains: Why do you want to expose implementation, if there is a public getter?

Stephan
  • 1,170
  • 7
  • 7