“Static methods may not communicate with instance fields, only static fields”. I got to read this quoted lines. When I studied other threads in this forum, I found that we can use instance fields in static methods and vice versa. So, what does this quote means?? Is it true?
Static methods may not communicate with instance fields, only static fields. I got to
Share
You can’t use non-static (instance) fields in static method. That’s because a static method is not associated with an instance.
A
staticmethod is one-per-class, while a class may have many instances. So if you have 2 instances, the fields of which one will the static methods see?Let’s imagine that this is valid:
And then: