|
Static methods
Hello bugger
CaptainMorgan's example explains how to call the static and non-static methods and not why someone would like to do that. Static methods can only access static attributes of a instanced class. For example: You have a class called Dog with a static field called numberOfDogs. In the constructor of Dog you can increment numberOfDogs and if you override the finalize method then you can decrement numberOfDogs. This way you can track how many Dog objects that you have created thanks to the static modifier. Now, you can add static methods to the Dog class to manipulate numberOfDogs without you having to create an instance of Dog Hope this helped. 
__________________
If your ship has not come in yet then build a lighthouse.
Last edited by tim : 01-04-2008 at 03:03 PM.
|