... passing reference to entire array:%n" +
11            "The values of the original array are:%n");
12
13         // output original array elements
14         for (int value : array) {
15            System.out.printf(" %d", value);
16         }
17
18         modifyArray(array); // pass array reference
19         System.out.printf("%n%nThe values of the modified array are:%n");
20
21         // output modified array elements
22         for (int value : array) {
23            System.out.printf(" %d", value);
24         }
25
26         System.out.printf(
27            "%n%nEffects of passing array element value:%n" +
28            "array[3] before modifyElement: %d%n", array[3]);
29
30         modifyElement(array[3]); // attempt to modify array[3]
31         System.out.printf(
32            "array[3] after modifyElement: %d%n", array[3]);
33      }
34
35      // multiply each element of an array by 2
36      public static ...

Get Java How to Program, Early Objects, 11th Edition now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.