Hey, Your code has problem. You declared a array with 10 elements,    "
int[] ages = new int[10];  ", you wanted to print  all elements of array,
but you declared  "int j = 100;". I think you should fix  like this :
public class ArrayTest {
>
>     /**
>      * @param args the command line arguments
>      */
>     public static void main(String[] args) {
>         // Declare and create new int array whose size is 10
>         int[] ages = new int[10];
>         int j = 0;
>         int count = 0;
>
>         // Display the values of each entry in the array
>         while (count<ages.length){
>               System.out.println(ages[j] );
>               count++;
>               j++;
>
>         }
>     }
>
>
>
> }

On Tue, Jan 4, 2011 at 1:17 PM, Michèle Garoche <migat...@gmail.com> wrote:

>
>
> On Jan 4, 12:25 am, Rene Olgers <ollie1...@gmail.com> wrote:
>
> >
> > public class ArrayTest {
> >
> >     /**
> >      * @param args the command line arguments
> >      */
> >     public static void main(String[] args) {
> >         // Declare and create new int array whose size is 10
> >         int[] ages = new int[10];
> >         int j = 100;
> >         int count = 0;
> >
> >         // Display the values of each entry in the array
> >         while (count<ages.length){
> >               System.out.println(ages[j] );
> >               count++;
> >               j++;
> >
> >         }
> >     }
> >
> >
> >
> > }
>
> To complete what others have already said, it would be probably better
> to fill your array with meaningful numbers, unless you insist in
> having 0 (the default value when none is supplied) in all elements, as
> you have just declared the array (that is allocated memory for it and
> initialize all elements to default value), but you have not
> initialized it (giving each element a value).
>
> In this case, just add at the top of the loop:
> ages[j] = j;
> to get 0,1, ... 9 for example
>
> Michèle Garoche
>
> --
> To post to this group, send email to
> javaprogrammingwithpassion@googlegroups.com
> To unsubscribe from this group, send email to
> javaprogrammingwithpassion+unsubscr...@googlegroups.com<javaprogrammingwithpassion%2bunsubscr...@googlegroups.com>
> For more options, visit this group at
> http://groups.google.com/group/javaprogrammingwithpassion?hl=en
>

-- 
To post to this group, send email to javaprogrammingwithpassion@googlegroups.com
To unsubscribe from this group, send email to 
javaprogrammingwithpassion+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/javaprogrammingwithpassion?hl=en

Reply via email to