Skip to content
Advertisement

Tag: overriding

Unable to override generic method in java

I am getting errors like Main.java:12: 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

How to properly add a value change listener to Map.Entry?

A project im working on currently requires me to ensure that while looping through a map’s entries, if Entry.setValue is called, it would trigger a value change event. I see I can try something like adding a listener into an extension of the Map class on the .put method. My question is, would entries being changed trigger a listener in

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

Advertisement