casting problems
Say that I have a stack of character, and I want to extract the value of those stack into an integer. How can I do that?
below is my code:
publicint value(){
int result = 0;
char right =' ';
char left =' ';
int number = 0;
String temp = this.postfix();
Stack<E> s =new Stack<E>();
for (int i = 0; i<temp.length(); i++){
char c = temp.charAt(i);
if (c !='+' && c !='-' && c !='/' && c !='%' && c !='*' && c!='(' & c!=')')
s.push(c);
elseif (c =='+' && c =='-' && c =='/' && c =='%' && c =='*'){
right = s.pop();
left = s.pop();
number = left + s.pop() + right;
s.push(number);
}
return result;
}
>

