Hi everybody,
i read your all message but we can explain it very easily that
why should i need static and why should i need non-static method
in different class. Some answer i found that it is not related with the class. I think it is somewhat related with the class.
Look,
Thread is a class and sleep() is a static method in that
class isn't it?. You might have a question. Why it is? Because
static void sleep() method is to be happened several times in
the class or subclass if it is being inherited by other class. Inherit means when you extend a class, you are able to use all features of that class in your subclass.
Thread.sleep(1000);
Static classes can be useful sometimes if you happen to have a very useful function in a class that you use a lot. Then it can be a good idea top make the function static and to be able to save some memory by not having to allocate memory for a new object. The memory that is required for a static method is allocated first when the Java VM encounters the class where the static method is. All the future objects created and based on that class will always use the same memory cell where the static method exist.
I think it should clear it out,
Golam Newaz
------------------