How to find the length of an array in Java?

To find the length of an array in Java, use the length field of the array.

Here's how you do it:

String[] myArray = new String[]{ "one", "two", "three" };

System.out.println(myArray.length); // 3