Tuesday 17 November 2015

Difference between this and super keywords

'this' is used for pointing the current class instance. It can be used with variables or methods.
Example:
In the above code this is used for the current instance. Since this is instance of a class it cannot be used inside a static method.
'super' is used for pointing the super class instance.
Example:
In the above example the super keyword is used for accessing the super class variable.

No comments:

Post a Comment