Eindoofus
asked on
Why is this character being pushed into the stack as it's decimal value?
I'm attempting to push a character into:
Stack<Double> s = new Stack();
By using the following line:
s.push(new Double(postfix.charAt(i))) ;
However, when I push the character '7' for example and try to pop it using:
double a = ((Double) s.pop()).doubleValue();
I get the decimal's character value 55 rather than the number 7. What am I doing wrong? What code will fix this?
Stack<Double> s = new Stack();
By using the following line:
s.push(new Double(postfix.charAt(i)))
However, when I push the character '7' for example and try to pop it using:
double a = ((Double) s.pop()).doubleValue();
I get the decimal's character value 55 rather than the number 7. What am I doing wrong? What code will fix this?
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Since Double doesnt accept a char in its constuctor, it implicitly casts the char to double, in doing so working with the numeric value (55).