What is the difference between the keywords this
and super
?
Both are used to access constructors of class right? Can any of you explain?
NOTE:
We can use super() and this() only in constructor not anywhere else, any attempt to do so will lead to compile-time error.
We have to keep either super() or this() as the first line of the constructor but NOT both simultaneously.
NOTE: We can use both of them anywhere in a class except static areas(static block or method), any attempt to do so will lead to compile-time error.