Return Modified Parameter

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


EditText of this page (last edited January 15, 2000) or FindPage with title or text search