I am trying to solve this question: https://uchicago.kattis.com/problems/uchicago.rpn
I've posted the Java code below for reference.
EDIT: I've removed the original code as it was too long and not too helpful. I think this post can be useful for future readers, if it can serve as a practical example that is able to underscore the difference between getBoolean() and parseBoolean() functions in Java. Further clarification can be found here. The bug turned out to be related to getBoolean() vs. parseBoolean() as can be seen from the code below, in which val1 and val2 were of the boolean types, as opposed to string names.
boolean bool1 = Boolean.getBoolean(val1);// Should be using parseBoolean(val1)
boolean bool2 = Boolean.getBoolean(val2);// Should be using parseBoolean(val2)
String result = booleanHelper(bool1, bool2, next);