0
Explain static methods ??with examples
2 Answers
+ 9
A static method can be invoked without creating an instance (object) of the class. For a dynamic method you need to instantiate an object to access it:
// static method
MyClass.method();
// or even just
method ();
// if you import the class
// dynamic
MyClass myClass = new MyClass();
myClass.method();
+ 1
Just to add on to @Tashi's answer. Static methods belong to the class so no matter how many objects you make of that class they will all share that particular method. Lot of people are consfused with this behaviour.