javac 1.8.0\u 77在不同系统上的编译结果不一致

oxcyiej7  于 2021-07-03  发布在  Java
关注(0)|答案(0)|浏览(176)

当我在mac上编译下面的代码时,我遇到了编译器错误。但是,当我在compilejava.net上编译相同的代码时,它运行良好。我相信在撰写本文时compilejava.net运行的是javac1.8.0\u77。
我在mac上使用的是JavaC1.8.0\u77。我的mac运行的是OSXV10.11.4,我在mac上尝试了JavaC1.8.092,结果也一样。有人能告诉我哪里可能出错吗?
代码:

import java.util.*;

public class CompilerError {
  public static void main(String[] args) {
    HashMap<Integer,Integer> tally = new HashMap<>();
    LinkedList<Map.Entry<Integer,Integer>> list = new LinkedList<>(tally.entrySet());
  }
}

错误(运行>javac compileerror.java的结果):

CompilerError.java:6: error: cannot infer type arguments for LinkedList<>
    LinkedList<Map.Entry<Integer,Integer>> list = new LinkedList<>(tally.entrySet());
                                                  ^
  reason: cannot infer type-variable(s) E
    (actual and formal argument lists differ in length)
  where E is a type-variable:
    E extends Object declared in class LinkedList
1 error

java版本输出

java version "1.8.0_77"
Java(TM) SE Runtime Environment (build 1.8.0_77-b03)
Java HotSpot(TM) 64-Bit Server VM (build 25.77-b03, mixed mode)

javac-version的输出

javac 1.8.0_77

暂无答案!

目前还没有任何答案,快来回答吧!

相关问题