Instead of testing against the size of the stack, why not use a while loop and test whether it is empty. I personally think it would be much safer than the for loop, though I honestly still don't see the difference with that code:
PHP Code:
while (!s.empty()) {
Object o1 = s.pop();
Object o2 = q.dequeue();
String num1 = (String) o1;
String num2 = (String) o2;
if (!num1.equals(num2)) {
result = "FALSE";
} else {
result = "TRUE";
}
}
I honestly can't see any problem from the code you've presented.