This week's book giveaway is in the Servlets forum.
We're giving away four copies of Murach's Java Servlets and JSP and have Joel Murach on-line!
See this thread for details.
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


Win a copy of Murach's Java Servlets and JSP this week in the Servlets forum!
JavaRanch » Java Forums » Java » Java in General
Bookmark " meaning of @override " Watch " meaning of @override " New topic
Author

meaning of @override

siddharth das
Ranch Hand

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

Joined: Aug 03, 2008
Posts: 9291
    
  17

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:
http://stackoverflow.com/questions/94361/when-do-you-use-javas-override-annotation-and-why


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
author
Sheriff

Joined: Oct 14, 2002
Posts: 8801
    
    5
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.

hth,

Bert


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

Joined: Oct 13, 2005
Posts: 37953
    
  22
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.
 
It is sorta covered in the JavaRanch Style Guide.
 
subject: meaning of @override
 
Similar Threads
WA #1.....word association
Finalizers in GC?
WA #2 ..... word association
Overriding and redefining
Class toString