When should I use static methods in a class and what are the benefits?

前端 未结 10 1434
孤独总比滥情好
孤独总比滥情好 2020-11-27 12:34

I have concept of static variables but what are the benefits of static methods in a class. I have worked on some projects but I did not make a method static. Whenever I need

10条回答
  •  囚心锁ツ
    2020-11-27 13:10

    Static variable is used when you want to share some info between different objects of the class.As variable is shared each object can update it and the updated value be available for all other objects as well. As static variable can be shared,these are often called as class variable.

提交回复
热议问题