Skip to content

Tag: overriding

Unable to override generic method in java

I am getting errors like error: TextMessage is not abstract and does not override abstract method setContent(T) in Message class TextMessage extends Message { ^ where T is a type-variable: T extends Object declared in method setContent(T) 1 error Answer Your method declaration: hides the type parameter declared in class. That causes the error, most probably you don’t need

What is addNotify();?

I’ve tried to find a laymans definition of addNotify() but I can’t really get any answer using Google. As far as I know, when overriding addNotify() in my class, I should call super.addNotify(); and then do whatever else afterward. My question is, does addNotify() run automatically? What is it’s purpose and what happens when I override it and furthermore, why