What is the use of a private static variable in Java?

前端 未结 19 2262
灰色年华
灰色年华 2020-12-02 03:47

If a variable is declared as public static varName;, then I can access it from anywhere as ClassName.varName. I am also aware that static members a

19条回答
  •  感情败类
    2020-12-02 04:12

    *)If a variable is declared as private then it is not visible outside of the class.this is called as datahiding.

    *)If a variable is declared as static then the value of the variable is same for all the instances and we no need to create an object to call that variable.we can call that variable by simply

    classname.variablename;

提交回复
热议问题