While learning Java, I wondered if there was a way to take an operator as a character input and use it directly in calculations. I realized that without using if or switch statements, there is no way to treat the character itself as an operator. I’m curious if anyone knows the reasons behind this limitation.
I wanted to use char ch = ‘+’ and have the + character act as the addition operator.
user26530492 is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.