In Java, the .length property is used to determine the length or size of an array. It is a built-in property for arrays and returns an integer value that represents the number of elements in the array.
The syntax of the .length property is the following:
arrayName.length;
The example below uses the .length property to determine the size of an array:
int[] numbers = 1, 2, 3, 4, 5>;int length = numbers.length;System.out.println("Length of the array is" + length)In this example, the numbers array contains five elements, and the .length property returns the value 5 , which is assigned to the length variable.
Output for the above code will be:
Length of the array is 5