I am implementing calculator with java.
So, I tried this:
If end of the string is not '+', '-', '*', '/', or '(', then add '+' at the end of the string.
So, I tried following code (assume that variable s
is 12345+
):
if(!s.matches("[-(+*/]$"))
s+="+";
But, the if statement(s.matches("[-(+-*/]$")
) does not return true
, am I wrong?? It works on linux's bash shell well.