Java Error - Illegal Modifier for Parameter - Only final Permitted

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

    Static declaration of a component makes in available on a class level. Declaring component in a method makes in available in method's stack memory hence can only be accessed through an object. Static belongs to the whole class. Therefore their is no point in declaring a variable static. You'll even get the compile time error if you try to do so. Final keyword has nothing related to memory.

提交回复
热议问题