So I have a stack that contains elements of type object. In these elements I'm saving characters.
As I said I'm saving chars in these elements. Now I would like to use these stack elements as characters. These are methods in my code, first one returns the data in the element and the second returns the element:
This is how I'm trying to cast, but it isn't working:
It gives me this error:
" StackElement cannot be cast to java.lang.Character"
StackElement is my node class. But why does it say this? Shouldn't I be converting an object to char since I called the getO() method?