C
Calvin
Hello.
import java.util.Stack;
private Stack myStack; // insance var
public void evaluate(String pExp)
{
myStack = new Stack();
char ch = pExp.charAt(0);
myStack.push(ch);
// myStack.push((char)pExp.charAt(0));
String result = (String)myStack.pop();
resultArea.append("Stack pop is : "+result);
}
At this point, I want to push a char and pop a char so I can continue
with my task but I can't simly push and pop a char. I know a stack
holds objects and when I did get a string pushed my pop worked, but
why wont eiter of my pushes work above (with char)?
I get:
The method push(Object) in the type Stack is not applicable for the
arguments (char)
I know this is simple, but a stack newbie I am. ( I have to use jav;s
stack clas object)
thanks
calvin
import java.util.Stack;
private Stack myStack; // insance var
public void evaluate(String pExp)
{
myStack = new Stack();
char ch = pExp.charAt(0);
myStack.push(ch);
// myStack.push((char)pExp.charAt(0));
String result = (String)myStack.pop();
resultArea.append("Stack pop is : "+result);
}
At this point, I want to push a char and pop a char so I can continue
with my task but I can't simly push and pop a char. I know a stack
holds objects and when I did get a string pushed my pop worked, but
why wont eiter of my pushes work above (with char)?
I get:
The method push(Object) in the type Stack is not applicable for the
arguments (char)
I know this is simple, but a stack newbie I am. ( I have to use jav;s
stack clas object)
thanks
calvin