Wednesday, January 07, 2009

Why use @Override annotation

If a method is annotated with @Override but does not correctly override a method (in one of the super-classes or interface), then the compiler will report an error. So this is a means to use the compiler to enforce your idea that the methods overrides some other method.

 

E.g. of a startElement() method exposed in ContentHandler.

 

    /**

     * ……

     */    

    @Override

    public void startElement(

            final String uri,

            final String localName,

            final String qName,

            final Attributes atts

    ) throws SAXException

    {……

 

No comments: