gpt4 book ai didi

java - 如何在java中定义KeyPairValue中的值

转载 作者:行者123 更新时间:2023-12-01 07:50:01 26 4
gpt4 key购买 nike

我的应用程序确实有很多角色。

private static HashMap<String, String> doctorcredentials = new HashMap<String, String>("doctor","Test1234!");

删除参数会引发错误。每次我只需要添加此凭据即可。不能直接定义吗?

最佳答案

HashMap 没有构造函数来支持您指定的参数。请引用documentation

要将值放入 HashMap 中,请按照下面的指定使用

HashMap<String, String> hm = new HashMap<String, String>(); 

hm.put("first", "FIRST INSERTED");
hm.put("second", "SECOND INSERTED");
hm.put("third","THIRD INSERTED");

关于java - 如何在java中定义KeyPairValue中的值,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/39697452/

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