加入收藏 | 设为首页 | 会员中心 | 我要投稿 李大同 (https://www.lidatong.com.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 编程开发 > Java > 正文

javac和Eclipse IDE编译器之间有趣的泛型相关差异

发布时间:2020-12-15 02:27:46 所属栏目:Java 来源:网络整理
导读:我在 javac和 Eclipse IDE编译器之间有一个有趣的差异,并且无法弄清楚谁是对的.所以,下面的代码用javac编译,但Eclipse告诉我静态初始化程序调用“exportAll”是错??误的,原因是: The method exportAll(Iterable X.Stat ? extends Number) in the type X is
我在 javac和 Eclipse IDE编译器之间有一个有趣的差异,并且无法弄清楚谁是对的.所以,下面的代码用javac编译,但Eclipse告诉我静态初始化程序调用“exportAll”是错??误的,原因是:

The method exportAll(Iterable< X.Stat< ? extends Number>>) in the type X is not applicable for the arguments (Collection< capture#1-of ? extends X.Stat>)

谁是对的? javac还是Eclipse?

import java.util.Map;

public class X {
  interface Stat<T> {
  }

  public static void exportAll(Iterable<Stat<? extends Number>> vars) {
  }

  public static Map<Double,? extends Stat> getPercentiles() {
    return null;
  }

static {
  exportAll(getPercentiles().values());
}

}

解决方法

它不能在javac中编译. (将静态添加到getPercentiles之后)

直截了当地了解事实;不要浪费别人的时间.

今天的孩子,ADD太多了.

(编辑:李大同)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章
      热点阅读