I need to pass an integer by reference in java . Is there a simple way to do so ? In C++ by putting "&" before an integer would be passed by reference . This is the C code that I'm trying to turn to Java :
void count(int distance, int i, int &counter, int array[], int n) {
if (i == distance)
counter++;
else {
for (int j = 0; j < n; j++) {
if (i <= distance - array[j])
count(distance, i + array[j], counter, array, n);
}
}
}
Is there a way to do so without having an integer object ?? (I don't want to make another class )