Win a copy of Design for the Mind this week in the Design forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

meaning of @override

 
siddharth das
Ranch Hand
Posts: 132
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
What is the meaning of @override in Java 1.5.
Thanks.
 
Ankit Garg
Sheriff
Posts: 9510
22
Android Google Web Toolkit Hibernate IntelliJ IDE Java Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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...
 
Satya Maheshwari
Ranch Hand
Posts: 368
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Here's a useful discussion on @Override:
http://stackoverflow.com/questions/94361/when-do-you-use-javas-override-annotation-and-why
 
Himanshu Gupta
Ranch Hand
Posts: 598
Android Eclipse IDE Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Can we get some detailed explanation on it?
 
Bert Bates
author
Sheriff
Posts: 8898
5
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
 
Campbell Ritchie
Sheriff
Posts: 48642
56
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic