What values are stored in the array at the comment in main
?
Note that the incrementAll
method returns void
, but does take an int[]
parameter.
public class ArrayReference {
public static void main(String[] args) {
int[] nums = {2, 4, -1, 3};
incrementAll(nums);
// HERE!
}
public static void incrementAll(int[] data) {
for (int i = 0; i < data.length; i++) {
data[i]++;
}
}
}
index | 0 | 1 | 2 | 3 |
---|---|---|---|---|
value | 3 | 5 | 0 | 4 |