precedence.put("+", 2); <=========== This is where the error occurs
this statement is not inside any block , hence it is not permitted.
remove it from here and put it inside any other method or block
Note: this is how java works.
for an extended discussion, please refer to:
Why can't I do assignment outside a method?