Help using a "while" loop!

Joined
May 24, 2003
Messages
5,794
Reaction score
0
This is in Java however I suspect its the same in C++ as well.

For the project I am doing I am being forced to use a while loop that will keep looping as long as a String is either A or B. However the compiler keeps returning an error stating that I can't have an "or" statement within the parameter for the loop. More specifically it is telling me:
operator || cannot be applied to boolean,java.lang.String

This is the line in question:

while(workStack.peek() == "*" || "/")

workStack.peek() returns a string.

Am I doing something wrong and it is possible to do what I want? Or do I have to find another way.
 
bliink said:
tried using just one "|"?
Just tried, no change. :(

EDIT: Ok I am an idiot suffering from a lack of sleep right now, problems fixed and it should have been obvious to me long ago.

This is what I should have had.
while(workStack.peek() == "*" || workStack.peek() == "/")

Thanks anyway.
 
Back
Top