Java Error - Illegal Modifier for Parameter - Only final Permitted

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

    you can not use public static modifier for a local variable. Do any of the followings

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

    or declare it as a member variable

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

    Remember that the final is the only modifer of the local variables

提交回复
热议问题