while (firstNodeNeedsToGo(text))
        {
            removeFirstNode();
            nodeRemoved = true;
        }

can someone rewrite this while loop into an if - then loop or any other code you have , this will help greatly toward my upcoming test

Edited 3 Years Ago by happygeek: fixed formatting

Not sure what you mean by "if then loop". "if" statements aren't loops. You only go through them once. What are you asking precisely?

Edited 3 Years Ago by happygeek: fixed formatting

so an if-then statement cant go on forever? an while loop cant be rewritten as if-then statement?

Well, if you wanted to make an "if" statement go on forever, I guess you could do something like this:

if (if condition)
{
     while (2 + 2 == 4)
     {
           // code
     }
}

That'd go on forever, but it's really a cheat since it's the while loop that's going on forever and the "if" evaluation still only gets executed once. Can't think of any way other than calling a recursive function that the "if" statement is in to make the "if" occur more than once, like this:

void foo ()
{
      if (if condition)
      {
            // code
            foo ();
       }
}

Unless you use a GOTO type statement, which I don't think exists in Java.

This question has already been answered. Start a new discussion instead.