Length of arrays

Edit on Github instead

Arrays remember their own length, which saves you from having to count each element. Each array has a instance variable length:

String[] names = new String[25];
names.length;               // returns 25

An array's .length is a variable, not a method, so you don't need parentheses to use it.

Suggest changes

Related links

URL Topic Source