Languages
[Edit]
EN

Java - get array length

0 points
Created by:
Alicia-Lambert
520

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

Alternative titles

  1. Java - get length of array
Donate to Dirask
Our content is created by volunteers - like Wikipedia. If you think, the things we do are good, donate us. Thanks!
Join to our subscribers to be up to date with content, news and offers.

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