File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes Java in General and the fly likes  meaning of @override Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Java in General
Bookmark " meaning of @override " Watch " meaning of @override " New topic

meaning of @override

siddharth das
Ranch Hand

Joined: Aug 17, 2007
Posts: 131
What is the meaning of @override in Java 1.5.
Ankit Garg

Joined: Aug 03, 2008
Posts: 9463

Siddhart @Override is an annotation that describes that the method on which it is put, overrides a method from a super-type. If the method doesn't override any method from a super-type, then there will be a compilation error.

Annotations are not a part of SCJP...

SCJP 6 | SCWCD 5 | Javaranch SCJP FAQ | SCWCD Links
Satya Maheshwari
Ranch Hand

Joined: Jan 01, 2007
Posts: 368
Here's a useful discussion on @Override:

Thanks and Regards
Himanshu Gupta
Ranch Hand

Joined: Aug 18, 2008
Posts: 598

Can we get some detailed explanation on it?

My Blog SCJP 5 SCWCD 5
Bert Bates

Joined: Oct 14, 2002
Posts: 8898
Ankit is correct !!!

Annotations are NOT on the exam. So, if you want to discuss annotations, and it is a wonderful topic!, then perhaps the intermediate forum would be a great place to do so.



Spot false dilemmas now, ask me how!
(If you're not on the edge, you're taking up too much room.)
Campbell Ritchie

Joined: Oct 13, 2005
Posts: 46348
I think you have already had a good explanation on the stackoverflow website which Satya Maheshwari quoted.

What a name for a website-stackoverflow!

There is an explanation in the Java Tutorials which is worth reading, and the answers on stackoverflow were useful.

Remember: the commonest reason for not correctly overriding a method is a simple mistake: find the MouseAdapter class and try a new class which has the MouseClicked method in. If you are not aware of the mistake you can spend hours and hours failing to work out what has gone wrong (I have seen that sort of error several times here on the Ranch).

I was a bit surprised that people on stackoverflow said you get errors because the superclass interface has been changed. That sounds like very bad practice: once a class has been deployed you mustn't alter any parts of its public interface, except maybe by adding new methods.
I agree. Here's the link:
subject: meaning of @override
It's not a secret anymore!