Saturday, May 28, 2011

Array Length in Java

Array Length in Java

         In order to get the number of elements in an array, you can use the length field of an array. The length field of an array returns the size of the array.
Syntax:  
             arrayName.length
Example:
            int[] num = new int [100];
            for (int counter = 0; counter<num.length; counter++)
{
System.out.print(num[counter]);

No comments: