简体   繁体   English

Eclipse IDE中的HASHMAP语法错误

[英]HASHMAP syntax error in eclipse IDE

For some, my eclipse IDE complains whenever I do something like this: 对于某些人,每当我执行以下操作时,eclipse IDE都会抱怨:

Map<Type,Type> map = new HashMap<Type,Type>();

it underlines Map and prefers I do something like this: 它强调了Map,并且更喜欢我这样做:

HashMap<Type,Type> map = new HashMap<Type,Type>();

Same goes for all the other interfaces. 其他所有接口也是如此。 What could be the problem with my eclipse? 月食可能是什么问题?

您必须import java.util.Map

Nothing's wrong with Eclipse (of course) assuming that you're using the Kepler release, but instead it's your settings that are off. 假设您使用的是Kepler版本,那么Eclipse没什么问题(当然),但是您的设置已关闭。 You need to set your Java Compiler compliance setting to 1.7. 您需要将Java Compiler合规性设置设置为1.7。 It's currently set at less than that. 当前设置为小于该值。

在此处输入图片说明

you must set your JAVA compiler to 1.7. 您必须将JAVA编译器设置为1.7。 for reference see my below picutre. 供参考,请参阅下面的图片。

在此处输入图片说明

Read exact error message and suggestions. 阅读确切的错误消息和建议。

Also check your current state of HashMap . 还要检查HashMap的当前状态。 Changing Map to HashMap is really an option, so Eclipse is correct. Map更改为HashMap实际上是一个选择,因此Eclipse是正确的。

The reason your Eclipse doesn't suggest to import Map is ambiguous. 您的Eclipse不建议导入Map是模棱两可的。

Type all line and imports by hand and save all files. 手动键入所有行和导入并保存所有文件。 Then check what Eclipse will say. 然后检查Eclipse会说些什么。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM