gpt4 book ai didi

java - 警告 : [unchecked] unchecked call to put(K, V) 作为原始类型 java.util.Hashtable localParams.put(name, values) 的成员;

转载 作者:搜寻专家 更新时间:2023-10-30 21:01:43 25 4
gpt4 key购买 nike

我有两个警告:-- 第一个是:

HELPDESKGESTION2\src\java\glpi\filter\LoginFilter.java:289: warning: [unchecked] unchecked call to put(K,V) as a member of the raw type java.util.Hashtable
localParams.put(key, value);
^

--第二个是:

HELPDESKGESTION2\src\java\glpi\filter\LoginFilter.java:292: warning: [unchecked] unchecked call to put(K,V) as a member of the raw type java.util.Hashtable
localParams.put(name, values);
^

生成此警告的代码是:

public void setParameter(String name, String []values) {
if (debug) System.out.println("LoginFilter::setParameter(" + name + "=" + values + ")" + " localParams = "+ localParams);

if (localParams == null) {
localParams = new Hashtable();
// Copy the parameters from the underlying request.
Map wrappedParams = getRequest().getParameterMap();
Set keySet = wrappedParams.keySet();
for (Iterator it = keySet.iterator(); it.hasNext(); ) {
Object key = it.next();
Object value = wrappedParams.get(key);
localParams.put(key, value);
}
}
localParams.put(name, values);
}

最佳答案

替换:

localParams = new Hashtable();

与:

localParams = new Hashtable<String,String>();

我假设您有一个如下所示的全局变量:

private Hashtable localParams;

将其替换为:

private Hashtable<String,String> localParams;

如果您进行我建议的更改,警告将会消失,但您还必须将所有对象替换为字符串;

关于java - 警告 : [unchecked] unchecked call to put(K, V) 作为原始类型 java.util.Hashtable localParams.put(name, values) 的成员;,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/7587270/

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