Scope of static variable and methods in Java

后端 未结 6 1363
自闭症患者
自闭症患者 2021-01-18 21:38

I have some doubts about usage of static method in Java. I read many places static variables are instance independent so be comes global.

public class ThirdC         


        
6条回答
  •  無奈伤痛
    2021-01-18 21:56

    It means the static variable are NOT global variable but only global to single execution!!!

    Of course they are. All variables that are not persisted to some kind of storage (like the hard disk) do not retain their values between distinct executions of the program.

提交回复
热议问题