Welcome to the Java Programming Forums


The professional, friendly Java community. 21,500 members and growing!


The Java Programming Forums are a community of Java programmers from all around the World. Our members have a wide range of skills and they all have one thing in common: A passion to learn and code Java. We invite beginner Java programmers right through to Java professionals to post here and share your knowledge. Become a part of the community, help others, expand your knowledge of Java and enjoy talking with like minded people. Registration is quick and best of all free. We look forward to meeting you.


>> REGISTER NOW TO START POSTING


Members have full access to the forums. Advertisements are removed for registered users.

Results 1 to 2 of 2

Thread: Simple While loop wont work??

  1. #1
    Junior Member
    Join Date
    Jan 2011
    Location
    Edinburgh
    Posts
    3
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Unhappy Simple While loop wont work??

    Hey Everybody!! Can someone please tell me why this doesnt work:

    int x = 0;
    Dog[] Dogs = new Dog[5];
    while (x < Dogs.length)
    {
    Dogs[x] = new Dog();
    }

    but this does???

    Dog[] Dogs = new Dog[5];
    Dogs[0] = new Dog();
    Dogs[1] = new Dog();
    Dogs[2] = new Dog();
    Dogs[3] = new Dog();
    Dogs[4] = new Dog();


    THANK YOU , Graeme


  2. #2
    Junior Member
    Join Date
    Jan 2011
    Location
    Edinburgh
    Posts
    3
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default Re: Simple While loop wont work??

    i fergot the x++

Similar Threads

  1. [SOLVED] ArrayOutofBoundary in Simple While Loop
    By Johnpower in forum Loops & Control Statements
    Replies: 6
    Last Post: June 13th, 2010, 04:31 AM
  2. [SOLVED] Simple Grahpic porgram wont work.
    By kogo50 in forum What's Wrong With My Code?
    Replies: 3
    Last Post: May 8th, 2010, 12:46 PM
  3. Can a for loop work with random number?
    By humdinger in forum Loops & Control Statements
    Replies: 7
    Last Post: January 10th, 2010, 10:06 PM
  4. boolean value in a simple loop (do-while)
    By chronoz13 in forum Loops & Control Statements
    Replies: 5
    Last Post: October 18th, 2009, 12:05 AM
  5. Why won't this while loop work?
    By trueblue in forum Loops & Control Statements
    Replies: 2
    Last Post: July 17th, 2009, 09:10 AM

Tags for this Thread