EN
Java - get array length
0 points
In this article, we would like to show you how to get array length in Java.
Quick solution:
xxxxxxxxxx
1
int[] array = new int[3];
2
System.out.println(array.length); // 3
In this example, we use array.length
to get the length of the array.
xxxxxxxxxx
1
public class Example {
2
3
public static void main(String[] args) {
4
int[] array = new int[3];
5
int result = array.length;
6
7
System.out.println("Length of the array = " + result); // 3
8
}
9
}
Output:
xxxxxxxxxx
1
Length of the array = 3