📜  非静态方法可以访问静态变量 - 无论代码示例

📅  最后修改于: 2022-03-11 14:57:10.401000             🧑  作者: Mango

代码示例1
Yes, a non-static method can access a static
variable or call a static method in Java.
There is no problem with that because of
static members . both static variable and
static methods belongs to a class and can be
called from anywhere, depending upon
their visibility. For example, if a
static variable is private then it can
only be accessed from the class itself,
but you can access a public static variable 
from anywhere by calling with classname.