Can non-static methods modify static variables

前端 未结 9 2081
猫巷女王i
猫巷女王i 2020-11-29 01:53

I am wondering how a non static method can modify a static variable. I know that static methods can only access other static methods and static variables. However, is the ot

9条回答
  •  攒了一身酷
    2020-11-29 02:15

    Static variables are class variable not instance or local variable . that is why we can use static variable in non static method also. and static variables are not per object . static variables have one copy that will be used in entire program.

提交回复
热议问题