Trusted answers to developer questions
Trusted Answers to Developer Questions

Related Tags

length
array
java

Length of an array in Java

Educative Answers Team

Array.length is a property of an array object in Java ​which returns the number of elements in the array.

svg viewer

Code

The code snippet below illustrates the usage of the Array.length property in Java:

class HelloWorld {
    public static void main( String args[] ) {
        int[] arr = {2, 4, 6, 8, 10}; 
        System.out.println("The length of the array is " + arr.length); 
    }
}

RELATED TAGS

length
array
java
Copyright ©2022 Educative, Inc. All rights reserved
RELATED COURSES

View all Courses

Keep Exploring