I'm trying to build an expression tree for the first time. There will be a prefix expression entered and I am thinking that I can check if there is an operator and if there is I can set the root node equal to the operator and if a number is the next character I can and the next char will be an int as well so i'd but I get an error because the interface is set to take TreeNode parameter. How Do I get it to accept an int as a TreeNode? This is what I have so far.
You do realise that the value of a char like '2' is not 2? A char is not a character, but a number, so you need to check whether you are passing 2, or more likely 0x32 (=50 in decimal) for that char '2'.