Search code examples
javajavadocpass-by-reference

How to correctly designate returning via argument reference in Javadocs


Suppose I have a method foo that is defined thus:

void foo(MyObject a, MyObject b) {
    a.set(1);
    b.set(2);
}

and I might call foo like so:

MyObject a = new MyObject();
MyObject b = new MyObject();
foo(a, b);

So I am "returning" from this function via passing the arguments by reference. How to I write the Javadocs for this?


Solution

  • For an example, have a look at the documentation for List.toArray(T[]):

    ...

    Parameters:
         a - the array into which the elements of this list are to
                be stored, if it is big enough; otherwise, a new array of
                the same runtime type is allocated for this purpose.

    ...