New to Java here.
I'm trying to pop the top two elements from a stack, add them together and push the result back onto the stack.
So far I have:
It seems to not allow me push an int onto the stack and asks for a token.
push(Token) in Stack <Token> cannot be applied to (int)
I'm trying to pop the top two elements from a stack, add them together and push the result back onto the stack.
So far I have:
Code:
Object a = stack.pop();
Object b = stack.pop();
int int1 = Integer.parseInt((String)a);
int int2 = Integer.parseInt((String)b);
stack.push(int1 + int2);
push(Token) in Stack <Token> cannot be applied to (int)
Comment