How do you use the array.length feature to determine what is in an array?
From ggc
The array.length field tells how many elements are in the array. This can be used to tell what is in the array. For example, here is some code that declares and initializes an array then prints out what is in the array.
int[] nums=new int[5];
nums[0]=4;
nums[1]=42;
nums[2]=14;
nums[3]=34;
nums[4]=45;
for(int x=0; x<nums.length; x++)
{
System.out.println("element "+x+" is "+nums[x]);
}
Does this help answer your question?
- This page was last modified on 1 April 2008, at 17:59.
- This page has been accessed 183 times.
- Privacy policy
- About ggc
- Disclaimers
- Powered by MediaWiki!









