Java Array Length

Ads
 

Java Array Length

The java array enables the user to store values of the same type in contiguous memory allocations.

The java array enables the user to store values of the same type in contiguous memory allocations.

Java Array Length

     

In this section, you will learn about the java array length.

The java array enables the user to store values of the same type in contiguous memory allocations. Arrays are always a fixed length abstracted data structure  which can not be altered when required.

The Array class implicitly extends java.lang.Object so an array is an instance of Object. Arrays have one named instance variable called length. It contains the length of an array (number of elements).

For getting length of array, you can use array_name.lenght.

String months[] = {"Jan", "Feb", "Mar", "Apr", "May",
 "Jun", "July", "Aug", "Sep", "Oct", "Nov", "Dec"};

months.lenght = 12;

To get more information about array click on:

http:/www.roseindia.net/java/language/introduction-to-java-arrays.shtml

 

Ads

Ads