Well, static is a little different from super and this, but I'll try to explain them all. First of all, let's talk about static. The keyword static is generally used to refer to something that is "class specific" rather than "object specific." For example, if you define a member to be static, that member belongs to the class, rather than to any specific object of that class. Let's look at an example.
As you can see from this code, the color of each box is an instance variable. It's value is different for every instance. The static variable numBoxesCreated, however, is often referred to as a "class variable." This member (since it is declared as static) is the same for all objects. In fact, this member exists without any objects being created at all. When you declare something as static, it belongs to the class, not to an instance of that class. Okay, now let's look at this and super. The keyword this refers to the object you're currently in. The keyword super refers to the object that the object you're currently in inherits from. Take this example:
By using the keywords this and super, you can explicitly refer to the object you're in or the object this object inherits from. This concept becomes increasingly useful when you're using complicated inheritance models with lots of method over-riding and shadowing. I hope this helps a little. If you have more specific questions, I'd be happy to help. Corey
By using the keywords this and super, you can explicitly refer to the object you're in or the object this object inherits from. This concept becomes increasingly useful when you're using complicated inheritance models with lots of method over-riding and shadowing. Corey
Hey when i compiled ur code it gave the following error
No when i declared the method doIt() as static it gave the error
How to go ahead??
Post by:autobot
I am mighty! And this is a mighty small ad:
a bit of art, as a gift, the permaculture playing cards