Unknown error relating to syntax of tokens

前端 未结 1 1027
滥情空心
滥情空心 2021-01-25 20:05

I can\'t work out what is wrong with the following code in Java:

import java.util.*;

public class stringCalculator {
    String operator_array[] = {\"+\", \"-\"         


        
相关标签:
1条回答
  • 2021-01-25 20:32

    You can not put statements directly inside a class.

    Create a method or a constructor and put the call to put there.

    public stringCalculator() {
        operatorPrecedence.put("+", "2");
    }
    

    Also, it is good practice to use an upper-case name for the class, like StringCalculator.

    0 讨论(0)
提交回复
热议问题