java 标记上的语法错误、错位的构造
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/13622992/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Syntax error on token(s), misplaced construct(s)
提问by Esailija
I've the code:
我有代码:
Map<String, String> map = new HashMap<String, String>;
Now in Eclipse is new HashMap<String, String>
red underlined.
现在在 Eclipse 中是new HashMap<String, String>
红色下划线。
The Error: Syntax error on token(s), misplaced construct(s)
What does it mean and how can i fix it?
这是什么意思,我该如何解决?
采纳答案by Michael Schmidt
Just add a ()! Map<String, String> map = new HashMap<String, String>();
只需添加一个 ()! Map<String, String> map = new HashMap<String, String>();
With new HashMap, you call the HashMap.java
. To initialize the HashMap, you should call the Constructer. Here with ().
使用new HashMap,您可以调用HashMap.java
. 要初始化 HashMap,您应该调用构造函数。这里用()。
回答by Esailija
It should be
它应该是
Map<String, String> map = new HashMap<String, String>(); //<-- add parentheses
回答by Bohemian
You are missing some brackets:
您缺少一些括号:
Map<String, String> map = new HashMap<String, String>();