posted 18 years ago
Hi Marcella,
Firstly, keep in mind that static members and instance members have opposite meanings.
Instance members :
Instance members belong to a particular instance of a Class.
So, if you have for example, an instance variable named as age, every time you create an instance by using new keyword, you will have a different and distinct age variable belonging to each instance created.
In this case, changes made in one instance specific DOESN'T affect the other instances already existing.
Static members :
Totally opposite from preceding explanation.
Static members belong to a class and NOT to a instance. In other words, a static member is shared through all instances for that class.
For example, supposing you have a class named as CarRent that contains informations about each car that was rented to a few customers.
Now, you want to know how many cars are rent at this moment, so, the best way to programatically represent this scenario is by using a static variable so that, every time your program creates a new rented car by using new CarRent() the class must add by one the static variable called totalCarRent.
So, every instance will share this variable and changes made by one instance will be reflected in another instance as well.
Hope that helps.
"If someone asks you to do something you don't know how to, don't tell I don't know, tell I can learn instead." - Myself