aitchnyu aitchnyu - 1 year ago 50
Java Question

What does @Override mean in this java code?

Possible Duplicate:

When do you use Java's @Override annotation and why?

Java, What does @Override mean?

I was checking out Drools Planner example source code and I came across code like this:

protected Solver createSolver() {
XmlSolverConfigurer configurer = new XmlSolverConfigurer();
return configurer.buildSolver();

protected Solver createSolverByApi() {
// Not recommended! It is highly recommended to use XmlSolverConfigurer with an XML configuration instead.
SolverConfig solverConfig = new SolverConfig();

return solverConfig.buildSolver();

As far as I understand
are supposed to return Solver objects when you explicitly call them.

What does the
mean here? What is the general meaning of the @ term?

EDIT: My very bad; I inadvertently duplicated Java, What does @Override mean?

Answer Source

The @ is Java Annotations.

The @Override means that the method is overriding the parent class (in this case createSolver).

The Javadoc states for @Override:

Indicates that a method declaration is intended to override a method declaration in a superclass.

This annotation is useful for compile-time checking to verify that the method you're overriding is valid (overridden correctly).