How to Find Array Length in Java?

Use the `.length` field on the array

Example: `int[] arr = {1, 2, 3};`

Example: `int size = arr.length;`

For a 2D array, use `.length` for the number of rows

Example: `int rows = matrix.length;`

For the length of a specific row in a 2D array, use `matrix[i].length`

Suggested for You

Trending Today