PDA

View Full Version : Java - Explaining the Override Annotation



Rog3r
June 21st, 2010, 15:18
Annotation:

The override annotation means that the following deceleration/methods is meant to override the deceleration/methods in the super class.

Basically the super class is the class that has the main method which is called automatically upon initialization of the class file.

The super class also extends to the child classes and in turn the child classes inherit from the super class. From there, you can assign new objects and such.

When you use the override annotation, it helps you program because it'll send a message about any spelling mistakes and secondly it makes your deceleration/methods more obvious of what it does since this annotation basically tells us that it over writes a deceleration/methods in the super class. In other, simpler words it's also referred to as a safe guard.

Usage:



@Override
public String hello() {
return "Hello YOU!";
}

Usually used in the child classes.

Mish
June 21st, 2010, 17:20
Nice good job mr Rogee

Trey
June 21st, 2010, 19:40
This part is wrong/needs to be rewritten:



Basically the super class is the class that has the main method which is called automatically upon initialization of the class file.

The super class also extends to the child classes and in turn the child classes inherit from the super class. From there, you can assign new objects and such.

Pie`
June 23rd, 2010, 19:53
It's not actually needed though.