相关疑难解决方法(0)

比较器<String>必须覆盖超类方法

我正在制作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 generics map treemap comparator

9
推荐指数
2
解决办法
1万
查看次数

带有Java 8补丁的Eclipse 4.3.2无法识别源级别1.8

我正在使用带有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支持还没有为黄金时间做好准备?

eclipse maven java-8 m2e maven-compiler-plugin

6
推荐指数
2
解决办法
2852
查看次数