loops - Java Stack - while pop-ing check pop content -


i want repeat calling function in while(), i.e.

while (temp=pop())     check temp     if found return true     else loop if finished looping not found     return false 

but can't seem implement while (temp=pop()). there other way this?

below attempt on coding it:

while(c1=g1.pop()){    if (c1.regis.equals(r) == false) {        np1.enqueue(c1.regis, 'a');        counter++;    }else if (c1.regis.equals(r) == true) {        while (np1.isempty() != true) {             c2 = np1.dequeue();             g1.push(c2.regis, c2.status);        }        counter = g1.checkspace();        return true;    }else{        return false;    } } 

while(c1=g1.pop()) can't work, , can't return true or false in while loop

the expression provided while must boolean in java, c1=g1.pop() evaluates new value of c1.

you need this:

while (!stack.isempty()) {     myobject next = stack.pop();     //... } 

Comments

Popular posts from this blog

apache - Remove .php and add trailing slash in url using htaccess not loading css -

javascript - jQuery show full size image on click -