java - Trying to cast an int to a character in a que -


i have queue of integers , characters , want cast them chars.

queue<object> rpnque = new linkedlist<object>(); rpnque.add(3); rpnque.add('+');  char ch1= (char) rpnque.poll();  

not working, trying cast object can math operators on them

write queue contains character.

queue<character> rpnqueue = new linkedlist<>(); 

then, write switch or equivalent if-else statement determine if character you've polled operator.

you have conversions , forth int (simply put, if isn't operator, subtract '0' (the char 0)).


Comments

Popular posts from this blog

css - I want to align grid in center -

Contact Form PHP Email Script -

python - SWIG function not printing output -