Unable to override methods of LocationListener class

拥有回忆 提交于 2019-12-05 15:53:06

Assuming that you are using Eclipse do the following to ensure that your compliance level is 1.6.

Go to Project -> Properties -> Java Compiler. There make sure that Compiler compliance level is set to 1.6.

You should set that level as a default value by navigating to Window -> Preferences -> Java -> Compiler. Select 1.6 for Compiler compliance level.

Someone should probably explain that:

  1. @Override wasn't supported for interfaces until Java 1.6.

  2. In Java 1.5, you cannot use @Override on a method to indicate it is intended to implement an interface method - the compiler will flag it as an override error. Under Java 1.5, you can use @Override only to indicate that the method is overriding a superclass method.

  3. Starting in Java 1.6, you can use @Override to indicate the method is intended to implement an interface method (too bad it wasn't a separate annotation like @Implements).

  4. Eclipse has a feature that can ensure your code compiles under a particular version of Java, regardless of what actual version of Java you have installed - this is the Compiler Compliance Level. If it is set to 1.5, even if your JDK is 1.6, the compiler will flag any code that would not compile under Java 1.5.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!