Because you did not enter values into the array. The default values for
array is 0 and when you declared the array, they all have the default value
and the loop states that it should print out the content of the array. You
can accomplish your mission using the loop statement alone as stated below;

for(int i=0;i<ages.length;i++)
       {
           System.out.print( i );
       }

Regards
On Wed, Nov 17, 2010 at 8:20 AM, Praveen D'Souza
<dsouzagprav...@gmail.com>wrote:

> 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
>
> --
> 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




-- 
DISCLAIMER
This message contains privileged and confidential information and is
intended only for the individual named. If you are not the intended
recipient you should not disseminate, distribute, store, print, copy or
deliver this message. Please notify the sender immediately by e-mail if you
have received this e-mail by mistake and delete this e-mail and any
attachments from your system. E-mail transmission cannot be guaranteed to be
secure or error-free as information could be intercepted, corrupted, lost,
destroyed, arrive late or incomplete or contain viruses. The sender
therefore does not accept liability for any errors or omissions in the
contents of this message which arise as a result of e-mail transmission.
Thank you   --   Tope Olukosi

-- 
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