Differences between jdk1.5 and 1.6 on override

Source: Internet
Author: User

@ Override is already available in JDK 5, but there is a small bug that does not support interface implementation.
JDK 6 fixes this bug. You can add @ override to both the method override of the parent class and the implementation of the interface.
I think this problem has certainly plagued many people, and I am no exception. New companies use something more or less different from what we used to do. So this problem is always with us.
Solution 1:
@ Override is already available in JDK 5, but there is a small bug, that is, it does not support the implementation of the interface. I think this is not override, and JDK 6 corrected this bug, you can add @ override to both the method override of the parent class and the implementation of the interface.
Modify the compiler version specified by your eclipse
In the Java compiler option, the specified version must be at least 5.0.
In myeclipse, change the compiler method: Project-> properties-> Java compiler-> Configure workspace setting, which can be set on the pop-up page.
This comes from: http://blog.csdn.net/CodeJoker/archive/2009/07/02/4317361.aspx

Solution 2: (no problem if I use this method)
In Java 1.5 and 1.6, @ override is used differently. Although JRE is changed, eclipse still reports an error.
Solution: Windows-> preferences --> JAVA-> compiler --> compiler compliance level is set to 6.0.
Note:
However, when importing a project, compile and package it into tomcat, you will find that Java. lang. unsupportedclassversionerror: bad version number in. class file exception. Check my myeclipse. I found that the JDK version of my eclipse compiler is inconsistent with that of Tomcat, and set it to be consistent later. It seems that this problem is caused.
During the deployment of the project on Linux, there were also problems caused by different versions. At that time, the IDE compiler we used was jdk5.0, And the Linux server was installed with jdk6.0, after deployment, I found that many functions were faulty. It seems that I have something to pay attention.
Appendix: how to change the compiler in myeclipse: Project-> ties of proper-> Java compiler-> Configure workspace setting. You can set it on the pop-up page.

In fact, this method is similar to the second one. The first method focuses on setting this project. The second option focuses on the project. However, they can all be used.

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.