Question #68234

public class P15 {
public static void main(String[] args) {
int[] v = { 0, 1, 2, 3 };
System.out.println(v[1] + ", " + v[2] + ", " + v[3]);
fiddle(v, v[2]);
System.out.println(v[1] + ", " + v[2] + ", " + v[3]);
fiddle(v, v[3]);
System.out.println(v[1] + ", " + v[2] + ", " + v[3]);
}

public static void fiddle(int[] array, int idx) {
array[idx] = array[idx - 1] + array[idx - 2];
}
}

Expert's answer

Output of this program is:

1, 2, 3

1, 1, 3

1, 1, 2

Method fiddle change the index.

Need a fast expert's response?

Submit order

and get a quick answer at the best price

for any assignment or question with DETAILED EXPLANATIONS!

LATEST TUTORIALS
APPROVED BY CLIENTS