I’m trying to build calculator in java. In order to build it, i have to split each integer into array. I divided each integer before and after “+” sign, by using split("\\+").
But what about other operators? Can I use “-“, “/”, “*” while using “+”?
In this case you can use
You need to write a simple parser if you want multi-digit numbers and negative numbers i.e.
-1+-2In the past I have used an enum based state machine to parse test. Once you have a stream of tokens you can build precedence rules.