Override from 5 to 6
One of the way of learning something is through exercise and trial and error process. And in the end you have the solution. Unfortunately, not everyone is documenting and sharing their learning.
This is a small tip that I learned while I had to maintain backward compatibility with Java 5 for an application written in Java 6.
While building the application, the compiler reported this error:
“method does not override a method from its superclass”. Even though it seems very strange, the cause is very simple.
Override annotation in Java 6 works for both methods in super classes and interfaces, as opposed to Java 5 where it works only for super classes. So actually in Java 6 this also means
Implement. Unfortunately, there is no reference about it in JavaDoc.
One more tip: if you’re using Eclipse is not enough to change the JDK. You also have to change the
Compiler compliance level. Just go to
Project > Properties > Java Compiler and select
Compiler compliance level.