+ 3
In which "@Override" used in java ?
2 Answers
+ 16
It's an annotation that prepares the compiler for overriding... Can be omitted....
+ 11
In addition to ValentinHacker's answer,
It works as a safety measure. If you use this annotation, the compiler will get to know that you're going to write an overriden method next. So it'll be able to show error if you make any mistake while writing the prototype.
public double calculateGrade(){ // parent method
// implementation
}
public double calculategrades(){
// overriden method in child class
// no error in spite of different spelling
}
@Override
public double calculategrades(){
/* will show error, because there's no matching prototype in parent class */
}
It's a good practice to use this annotation to avoid mistake.



