Java String array: is there a size of method?

array.length

It is actually a final member of the array, not a method.


Also, it's probably useful to note that if you have a multiple dimensional Array, you can get the respective dimension just by appending a '[0]' to the array you are querying until you arrive at the appropriate axis/tuple/dimension.

This is probably better explained with the following code:

public class Test {
    public static void main(String[] args){
        String[][] moo = new String[5][12];

        System.out.println(moo.length); //Prints the size of the First Dimension in the array
        System.out.println(moo[0].length);//Prints the size of the Second Dimension in the array
    }

}

Which produces the output:

5
12

array.length final property

it is public and final property. It is final because arrays in Java are immutable by size (but mutable by element's value)


Yes, .length (property-like, not a method):

String[] array = new String[10];
int size = array.length;