Java Error - Illegal Modifier for Parameter - Only final Permitted

前端 未结 8 769
既然无缘
既然无缘 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:31

    Your can not declare a local variable(variables inside methods are local variables) as public static. Instead, the following code will work:

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

提交回复
热议问题