Search code examples
javaarraysintjavadoc

Show Array Value in JavaDocs


Lets say I have got such code:

private static final int[] ARRAY = {5, 10, 15};

/**
 * ????
 */
public void doSomething()
{}

I am wondering, if is there any way to put value of the ARRAY into documentation of doSomething() method. I can see that @value #ARRAY isn't working at all for arrays :( @link #ARRAY is not showing me the value.

Am I missing something?


Solution

  • The problem is that @value only works for constants, i.e. static final values. The array contents are not constants, only the array object itself is. You can change the values at any time. So it doesn't make sense, technically, to show the values. The array object itself can't be shown at Javadoc creation time in any useful way, like any other object (except Strings).