When to use static methods

前端 未结 21 1909
旧巷少年郎
旧巷少年郎 2020-11-21 05:05

I am wondering when to use static methods? Say if I have a class with a few getters and setters, a method or two, and I want those methods only to be invokable on an instanc

21条回答
  •  逝去的感伤
    2020-11-21 05:40

    No, static methods aren't associated with an instance; they belong to the class. Static methods are your second example; instance methods are the first.

提交回复
热议问题