Difference between Static methods and Instance methods

前端 未结 10 1311
青春惊慌失措
青春惊慌失措 2020-11-22 05:30

I was just reading over the text given to me in my textbook and I\'m not really sure I understand what it is saying. It\'s basically telling me that static methods or class

10条回答
  •  春和景丽
    2020-11-22 06:10

    Instance method vs Static method

    1. Instance method can access the instance methods and instance variables directly.

    2. Instance method can access static variables and static methods directly.

    3. Static methods can access the static variables and static methods directly.

    4. Static methods can’t access instance methods and instance variables directly. They must use reference to object. And static method can’t use this keyword as there is no instance for ‘this’ to refer to.

提交回复
热议问题