Java Error - Illegal Modifier for Parameter - Only final Permitted

前端 未结 8 772
既然无缘
既然无缘 2020-12-03 01:32

What\'s wrong with the below Code

public static void main(String[] args){
        public static final String Name = \"Robin Wilson\";
    }

8条回答
  •  情书的邮戳
    2020-12-03 02:30

    You can't declare this inside main, put it outside the method, you want it as a [class member]:

    public static final String Name = "Robin Wilson";
    public static void main(String[] args) throws IOException {  }
    

    Otherwise(I don't think this is what you want) just remove public static from there and simply write:

    public static void main(String[] args){
        final String Name = "Robin Wilson";
    }
    

提交回复
热议问题