Suppose I have a class A, with it’s own instance variables. It has a method called doSomething(), which is a static method. Now, A adds another class B as some pointer. Say inside class B, I run some logic and determine that I need to run the code contained in doSomething(). Is it ok for me to just say A.doSomething()? And if I have an instance of A called a, does a‘s doSomething() method get invoked?
Suppose I have a class A , with it’s own instance variables. It has
Share
If you invoke
A.doSomething()it will just execute that static method. Sayinga‘sdoSomethingdoes not make sense because static methods do not belong to an object or instance of your class.