Suppose I have this in C++:
void test(int &i, int &j) { ++i; ++j; }
The values are altered inside the function and then use
Java does not have pass-by-reference. You must encapsulate to achieve the desired functionality. Jon Skeet has a brief explanation why pass-by-reference was excluded from Java.