When to use static methods?
I am aware that we use static method when its behaviour is same irrespective of how many objects gets instantiated from same class.Suppose if i have a class Test with method add
Class Test
{
public int add(int a, int b)
{
return a+b;
}
}
For the above example is it good to use static keyword or not? Can someone explain me with good reasoning.
Re: When to use static methods?
Quote:
behaviour is same irrespective of how many objects gets instantiated
Your reason sounds good.
Re: When to use static methods?
Are there any other reasons as when to use static method vs when not to use. does static method takes more memory?