title: Cannot cast from Object to char
body: <p>My code works perfectly as far as I can see but I still get the error "Cannot cast from Object to char" and I was wondering if anyone could explain to me what the problem is and if I can do it another way that does not cause an error.</p>
  
  <p>This is the bit of code causing the error <code>char op = (char) term;</code>. It is from an infix to postfix converter</p>
  
  <pre><code>//Take terms off the queue in proper order and evaluate
  private double evaluatePostfix(DSAQueue&lt;Object&gt; postfixQueue) {
      DSAStack&lt;Double&gt; operands = new DSAStack&lt;Double&gt;();
      Object term; 
  
      //While still terms on queue, take term off.
      while(!postfixQueue.isEmpty()) {
          term = postfixQueue.dequeue();
          if(term instanceof Double) { //If term is double put on stack
              operands.push((Double) term);
          }
          else if(term instanceof Character) { //If term is character, solve
              double op1 = operands.pop();
              double op2 = operands.pop();
              char op = (char) term;
              operands.push(executeOperation(op, op2, op1));
          }
      }
      return operands.pop(); //Return evaluated postfix
  }
  </code></pre>
  
  <p>Any help (even pointing me to some reading) would be much appreciated. </p>