I am dizzy with jdk5-@ override for n times ..

Source: Internet
Author: User

When changing the eclipse compiling environment from JDK 6 to JDK 5 many times, almost all @ override writes under JDK 6 will report errors. Think twice about it.
I found the cause on the Internet :)

@ Override is introduced by JDK 5 and is described as follows:
Indicates that a method declaration is intended to override a method declaration in a superclass. if a method is annotated with this annotation type but does not override a superclass method, compilers are required to generate an error message.

The descriptions in JDK 6 are exactly the same! But the real trouble lies in the understanding of superclass! JDK 5 considers override overload to overwrite the parent class method, while JDK 6 defines both the parent class method and the implementation interface method as override superclass. Therefore, as long as @ override is written to implement the interface method, jdk5 will report an error.

 

I personally think that the @ override of JDK 5 may be a bug during design. :) it seems that JDK 6 has a correct understanding.

 




 

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.