| 20 | .toCharArray(); |
| 21 | static char getChar(int n) { return chars[n]; } |
| 22 | public static void main(String[] args) { |
| 23 | int[] ia = new int[SZ]; |
| 24 | long[] la = new long[SZ]; |
| 25 | double[] da = new double[SZ]; |
| 26 | Arrays.setAll(ia, n -> n); // [1] |
| 27 | Arrays.setAll(la, n -> n); |
| 28 | Arrays.setAll(da, n -> n); |
| 29 | show(ia); |
| 30 | show(la); |
| 31 | show(da); |
| 32 | Arrays.setAll(ia, n -> val++); // [2] |
| 33 | Arrays.setAll(la, n -> val++); |
| 34 | Arrays.setAll(da, n -> val++); |
| 35 | show(ia); |
| 36 | show(la); |
| 37 | show(da); |
| 38 | |
| 39 | Bob[] ba = new Bob[SZ]; |
| 40 | Arrays.setAll(ba, Bob::new); // [3] |
| 41 | show(ba); |
| 42 | |
| 43 | Character[] ca = new Character[SZ]; |
| 44 | Arrays.setAll(ca, SimpleSetAll::getChar); // [4] |
| 45 | show(ca); |
| 46 | } |
| 47 | } |
| 48 | /* Output: |
| 49 | [0, 1, 2, 3, 4, 5, 6, 7] |