ReturnModifiedParameter

Last edit January 15, 2000
This is one of the AlternativesToPassByReference.

If your function is modifying its parameter, return the modified parameter instead:

  int addOne (int i)
    {
    return i + 1;
    }

...

int i = 2; i = addOne (i); System.out.println (i);

3