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:
int[] array = new int[3];
System.out.println(array.length); // 3
Practical example
In this example, we use array.length
to get the length of the array.
public class Example {
public static void main(String[] args) {
int[] array = new int[3];
int result = array.length;
System.out.println("Length of the array = " + result); // 3
}
}
Output:
Length of the array = 3