inFix to postFix

I've developed a Doubly Linked List which controls a Stack I have also designed.

I am using the Stack to implement a infix to postfix conversion tool.

Perhaps this should be under another forum topic, but my issue is that my DLL and Stack have been developed to accept Object, and my infix to postfix needs to use char during the push and pop methods.

How do I push or pop a char, when the parameter and return type (respectively) are Objects?

Thank you.

[486 byte] By [tkssa] at [2007-10-3 6:56:29]
# 1

You can use the wrapper class Character. Here's an example:

Stack stack = new Stack();

// push some Character objects on the stack

stack.push(new Character('3'));

stack.push(new Character('+'));

stack.push(new Character('8'));

while(!stack.empty()) {

// convert back from object to char

char temp = ((Character)stack.pop()).charValue();

System.out.print(temp+" ");

}

http://java.sun.com/j2se/1.4.2/docs/api/java/lang/Character.html

Good luck.

prometheuzza at 2007-7-15 1:48:30 > top of Java-index,Other Topics,Algorithms...