我在Mac OS X 10.5(JDK合规级别5.0)上使用Eclipse中的Java,并且我遇到了一些我之前没有遇到的非常奇怪的编译问题(我认为我没有更新我的编译器或Eclipse ,但也许安装了我不知道的更新).例如,如果我的代码中包含以下行:
List foo = new LinkedList();
Run Code Online (Sandbox Code Playgroud)
我收到一条警告:
Exception in thread "main" java.lang.Error: Unresolved compilation problem:
Type mismatch: cannot convert from LinkedList to List
Run Code Online (Sandbox Code Playgroud)
谁知道什么是错的?
谢谢
akf*_*akf 12
我会检查ListEclipse导入的是哪个.如果它是GUI java.awt.List,则它不是实现的java.util.List接口,LinkedList因此会导致编译时错误.