Sobes.tech
Junior — Middle

How to determine the number of elements in an array?

sobes.tech AI

Answer from AI

In Java, to determine the number of elements in an array, the length property is used. For example:

int[] numbers = {1, 2, 3, 4, 5};
int size = numbers.length; // size will be 5

Note that length is a field of the array, not a method, so parentheses are not needed.