while(true)--This one would be an infinite loop. There is no expression that is going to evaluate. The only way to get out of this loop is a break statement. while (x == true)--This is a boolean expression that will evaluate to either true or false based on the value of x. If x is true, the expression will evaluate to true. If x is false, the expression will evaluate to false.

while(x=true)--I am not completely sure about this one, but I think I got it. This is an assignment statement, not a comparison. So here you are assigning a value of true to x, and then x evaluates to true.

while(x=true)--I am not completely sure about this one, but I think I got it. This is an assignment statement, not a comparison. So here you are assigning a value of true to x, and then x evaluates to true.

Yep, you are assigning true to x and the evaluating the loop

while (x == true)--This is a boolean expression that will evaluate to either true or false based on the value of x. If x is true, the expression will evaluate to true. If x is false, the expression will evaluate to false.

So it has the same effect as while (x) ...

The soul is dyed the color of its thoughts. Think only on those things that are in line with your principles and can bear the light of day. The content of your character is your choice. Day by day, what you do is who you become. Your integrity is your destiny - it is the light that guides your way. - Heraclitus

...and you have discovered that all expressions (including expressions that involve an assignment operator) create a return value. So, an assignment expression also represents some value. [ November 12, 2002: Message edited by: Dirk Schreckmann ]

This only works for booleans in Java afaik (as opposed to C/C++). In C and C++ the result of an assignment ( x=y ) will always be true if y is nonzero. In Java, the result of this expression is not a boolean (unless you're assigning a boolean value) and it will give a compile-time error.