我正在制作TreeMap<String, String>并希望以降序的方式订购它.我创建了以下比较器:
Comparator<String> descender = new Comparator<String>() {
@Override
public int compare(String o1, String o2) {
return o2.compareTo(o1);
}
};
Run Code Online (Sandbox Code Playgroud)
我像这样构造TreeMap:
myMap = new TreeMap<String, String>(descender);
但是,我收到以下错误:
The method compare(String, String) of type new Comparator<String>(){} must override a superclass method
Run Code Online (Sandbox Code Playgroud)
我从未完全弄清楚仿制药,我做错了什么?
我正在使用带有Java 8补丁的 Eclipse 4.3.2 ,以及m2e和Subclipse,完全更新到所有版本的最新版本.
我为我们的项目进入Maven POM并将maven-compiler-plugin更改为:
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>2.5.1</version>
<configuration>
<source>1.8</source>
<target>1.8</target>
Run Code Online (Sandbox Code Playgroud)
我更新了所有我的Maven项目,试图做一个完整的清理和构建.各处都有错误.暂时忽略内部编译器错误,我看到的错误是:
Syntax error, static imports are only available if source level is 1.5 or greater
Run Code Online (Sandbox Code Playgroud)
我正在运行Java 1.8 ---为什么我收到此消息?m2e应该受到责备吗?maven-compiler-plugin?或者Eclipse Java 1.8支持还没有为黄金时间做好准备?