Java Array Length

Java array is a collection of similar data type which store elements in a contiguous memory location.

Java Array Length

In this section you will find a program to find the length of array in java. An array is collection of similar data type. To find the length of array is a simple program in java. Using length function you can find the length of array.

Syntax :  array-name. length

Example : int a[]  = { 10,20,30,40,50};

If you have to find the length of an array a, you can use a.length, it will return the length of array i.e. 5.

Code to find the length of an array

public class Length {
	public static void main(String args[])
		int a[]= {12,23,0,90,76,40};
		System.out.print("Length of array = ");

In the above code declaration and initialization of  an array a, and finding the length of an array by a.length, returning the length of array a.

Output: When you compile and execute the code output will as below:

Share on Google+Share on Google+

Java Array Length

Posted on: June 13, 2013 If you enjoyed this post then why not add us on Google+? Add us to your Circles



Discuss: Java Array Length  

Post your Comment

Your Name (*) :
Your Email :
Subject (*):
Your Comment (*):
  Reload Image