How come in the first code block of this Runnable implementation there is no @Override
annotation on run()
? - run()
is an abstract method:
handler = new Handler();
final Runnable r = new Runnable() {
public void run() {
tv.append("Hello World");
handler.postDelayed(this, 1000);
}
};
handler.postDelayed(r, 1000);
Compare this to my Android onCheckedChanged
function which is also an abstract method:
currentlocation.setOnCheckedChangeListener(object: RadioGroup.OnCheckedChangeListener{
override fun onCheckedChanged(group: RadioGroup?, checkedId: Int) {
}
})
which has to have the override
modifier (note: that's kotlin code but same principles apply).
How come the 2nd the 2nd code block needs to have the override keyword but the first doesn't?