Java String array: is there a size of method?

In Java, you can use the length field of an array to determine the size of the array. For example, given an array arr, you can get the size of the array using arr.length.

For example:

String[] arr = {"apple", "banana", "cherry"};
int size = arr.length;

System.out.println("Size of array: " + size);

This will output the following:

Size of array: 3

Keep in mind that the length field is a field of the array object, not a method. Therefore, you do not need to use parentheses after length when accessing it.

I hope this helps! Let me know if you have any questions.