这是我的 HashMap :
protected HashMap<String, HashMap<String, Player>> prisonsPlayers = new HashMap<String, HashMap<String, Player>>();
我尝试在其中插入一些内容:
prisonsPlayers.put(player.getWorld(), (HashMap<player.getName(), player>));
我得到的错误:
Multiple markers at this line
- Syntax error, insert ")" to complete
Expression
- Syntax error on token ")", invalid
Expression
我知道我做错了什么,但无论我如何尝试,无论我做什么,我都不知道如何将该数据插入到我的 HashMap 中。
最佳答案
这一行
prisonsPlayers.put(player.getWorld(), (HashMap<player.getName(), player>));
应该是这样的
Map<String, Player> map = new HashMap<String, Player>();
map.put(player.getName(),player);
prisonsPlayers.put(player.getWorld(), map);
关于java - Hashmap 在 HashMap 中尝试插入一些东西,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/20685173/