> public class JavaArray {
>
> /**
> * @param args the command line arguments
> */
> public static void main(String[] args) {
>
> // Declare and create int array whose size is 10
> int[] ages = new int[10];
>
> // Display the value of each entry in the array
> for( int i=0; i<ages.length; i++ ){
> System.out.print( ages[i] );
> }
> }
>
> }
>
> y does it print 0 9 times..i am confused.. i taught i would print 0 1
> 2 3 4 5 6 7 8 9..please someone explain..thanks
Because you only initialize the Array, but do not assign any values.
For example:
int[] ages = new int[] {0,1,2,3,4,5,6,7,8,9};
CU,
Gert
--
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/javaprogrammingwithpassion?hl=en