Im having trouble extracting the String data from a stack and converting it to int to perform arithmetic, it keeps telling me that i cannot cast a string to an int and vice versa, however i don't know any other alternative methods. this is the code i have:
int t1 = Integer.parseInt((String)stk.pop());
int t2 = Integer.parseInt((String)stk.pop());
int z;
switch(current) {
case '+':
z = t2 + t1;
break;
case '-':
z = t2 -t1;
break;
case '*':
z = t2 * t1;
break;
case '/':
z = t2 / t1;
break;
default: z = 0;
}
stk.push(z);
if(!moreSymbols.hasNext()) {
String result = (String)stk.pop();
}