You can combine array creation and element insertion by using an array initializer, in which specific elements appear, separated by commas, and surrounded by brackets:
int durations [] = {65, 87, 72, 75};
The array initializer shown specifies that an array is to be created, that
the array is to store four elements, and that the initial values are to be
65
, 87
, 72
, and 75
. Thus, one statement takes
the place of five:
int durations[] = new int [4]; durations[0] = 65; durations[1] = 87; durations[2] = 72; durations[3] = 75;