Skip to main content
Java Output Prediction Medium +20 XP

Array Length

What is the output?

JavaRead-only
int[] arr = {10, 20, 30};
System.out.println(arr.length);

What is the output?

Show answer and explanation

Answer: 3

The .length property returns the number of elements in the array, which is 3.

Hint: Count the elements.

What this challenge tests

Output Prediction in Java: arrays, properties.

Related challenges