I am still trying to learn java, so correct me if I’m wrong.
As I understand it, the super keyword calls the constructor of a class. So I do not understand what the significance of saying
super.paint(g)
does for example, or more recently while reading about animation I came across
super.addNotify()
I tried looking up documentation on the two (perhaps poorly) and it didn’t satisfy my curiosity adequately, so here we are.
Any clarification on those two example or in general would be appreciated. Thanks!
superis a keyword that is a reference to the superclass of the class from which you are using the keyword.So
super()calls the constructor of the superclass,super(x)calls a parameterised constructor, andsuper.paint(g)calls thepaint()method of the superclass.