I'm trying to convert a char to Character before it gets pushed on a stack but get a "cannot find symbol error", I don't see what the problem might be. This is how I pass the char to the stack:
stack.push(valueOf(in));
Where 'in' is a char.
valueOf
is a class method of Character
, among others. You can't just call it without a class to hang it off.
What you're really looking for is
Character.valueOf(in)
or new Character(in)
.
You are looking for:
stack.push(Character.valueOf(in));
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With