Search code examples
static-methodsstateless

What do you mean by stateless in static method?


Static method should not contain a state. What does 'state' means here ?

I have read that static method do not need to be instantiated, and do not use instance variables. So when can I use static methods? I have read that static methods are bad? Should I include it when coding?


Solution

  • State means storing some information, static methods are loaded when a class is loaded so there is no need of instance to call the static methods, you can call this methods using name of class, it's depend on condition when to use static methods. you can use static methods as single component of product just pass your parameters and get your work done.