本文介绍了如何在Main方法中声明静态变量?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我们可以在主
方法中声明静态
变量吗?因为我收到错误消息:
Can we declare Static
Variables inside Main
method? Because I am getting an error message:
Illegal Start of Expression
推荐答案
显然,不,我们不能。
In Java, static
表示它是类的变量/方法,它属于整个类,但不属于某个特定对象之一。
In Java, static
means that it's a variable/method of a class, it belongs to the whole class but not to one of its certain objects.
这意味着 static
关键字只能在'类范围'中使用,即它在方法内部没有任何意义。
This means that static
keyword can be used only in a 'class scope' i.e. it doesn't have any sense inside methods.
这篇关于如何在Main方法中声明静态变量?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!