I am new to Java and Android programming. The issue that I am having is that after surfing several books, forum and websites, I do not have clear understanding of what the @override annotation does. I understand it signifies when a method is being over ridden. but why is it needed in android. I see it rarely in source code for java, but all the time in android.
Share
You may see it rarely in old Java source code, because it’s a fairly recent innovation – whereas Android code is more recent pretty much by definition.
It’s a safety net, really – it tells the compiler that you’re trying to override something – so please fail if the method doesn’t override anything, e.g. due to a typo in the name. It’s just like
overridebeing a keyword which is part of the method declaration in C#. It helps you to be explicit about what you’re doing, which helps to prevent mistakes and also makes your code clearer to future readers.