I want to pass one of four operators (+, -, *, /) to a method, and have it perform an operation on two integers based on which operator was passed.
static int op(String oper) {
eval = 8 oper 4;
}
e.g. if I call it with op("+");
, it'll add 8
and 4
.
Right now, I just get a ";
expected" after 8
.
Is there some other syntax I should use? I'm just trying to cut down the size of some code.