Static methods can be called without using the class reference (object). Following are the two reasons, one can use static methods:
Documentation Anyone seeing that a method is static will know how to call it (see below). Similarly, any programmer looking at the code will know that a static method can't interact with instance variables, which makes reading and debugging easier.
Efficiency A compiler will usually produce slightly more efficient code because no implicit object parameter has to be passed to the method.
Documentation Anyone seeing that a method is static will know how to call it (see below). Similarly, any programmer looking at the code will know that a static method can't interact with instance variables, which makes reading and debugging easier.
Efficiency A compiler will usually produce slightly more efficient code because no implicit object parameter has to be passed to the method.
Comments