Languages
[Edit]
EN

Java - get array length

0 points
Created by:
Alicia-Lambert
340

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

Java - Arrays (popular problems)

Native Advertising
🚀
Get your tech brand or product in front of software developers.
For more information Contact us
Dirask - we help you to
solve coding problems.
Ask question.

❤️💻 🙂

Join