What is the difference between a static variable and a dynamic variable in java/oops?

前端 未结 8 823
情话喂你
情话喂你 2021-01-28 12:22

please someone tell me the difference between a \'static variable\' and a \'normal variable\' in oops or in java. Also their usage if possible.

8条回答
  •  时光说笑
    2021-01-28 13:11

    Consider a class having static and dynamic variables.

    • Dynamic variables : When instance of the class is created, each object has its own copy of dynamic variables. Values of this variables will be different for each object, whatever the value is assigned to it in that object.
    • Static variable : These are class level variables. The value of these variables will be shared among all the objects of the class. When one of the object changes its value that will be the latest value available for other objects. That means these are the shared variables.

提交回复
热议问题