gpt4 book ai didi

java - 如何修复 "the method put(string, string) is undefined for the type string"?请

转载 作者:行者123 更新时间:2023-12-02 03:25:59 25 4
gpt4 key购买 nike

 package Utils; 

import java.util.HashMap;

import org.bukkit.entity.Player;

public class KitApi {

public static HashMap<String, String> kit = new HashMap<>();

public static void setKit(Player p, String kit) {
kit.put(p.getName(), kit);
}

public static String getKit(Player p) {
if (kit.containsKey(p.getName())) {
return kit.get(p.getName());
} else {
return "nenhum";
}
}
}

最佳答案

重命名 map 或参数。参数 kit 遮盖了 map 的名称。例如:

 public static void setKit(Player p, String _kit) {
kit.put(p.getName(), _kit);
}

关于java - 如何修复 "the method put(string, string) is undefined for the type string"?请,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/38882462/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com