Java - What is the output: array length update?


What is the output of the following code?

int[] roll = new int[5]; // Create an array of 5 elements
roll.length = 10;

Click to view the answer

// A compile-time error. 
roll.length = 10;


The length property of an array is final. You cannot modify it.

You cannot change the length of an array after it is created.