Convert String to operator(+*/-) in java

前端 未结 5 1283
时光说笑
时光说笑 2021-01-06 05:57

I am using Stack class to calculate simple arithmetic expressions involving integers, such as 1+2*3.your program would execute operations in the order given,without regardin

5条回答
  •  耶瑟儿~
    2021-01-06 07:03

    You will have to manually check and assign the operator. E.g.

    if (s.equals("+")) {
        // addition
    }
    

提交回复
热议问题