Java 创建通用哈希表时出错

Java 创建通用哈希表时出错,java,collections,hashtable,Java,Collections,Hashtable,尝试创建泛型哈希表时出现以下错误 类型哈希表中的方法put(String,capture#2-of?)不适用于参数(String,int) 我需要一个哈希表,如下所示: HashTable 我说的AnyWrapperType是指它可以是整数、字符串、字符或布尔值 我使用了?作为AnyWrapperType,但是我得到了一个错误 我也从我知道自己做错了什么但能找到出路的地方开始 Hashtable<String, Hashtable<String, String>>

尝试创建泛型哈希表时出现以下错误

类型哈希表中的方法put(String,capture#2-of?)不适用于参数(String,int)

我需要一个哈希表,如下所示:
HashTable

我说的AnyWrapperType是指它可以是整数、字符串、字符或布尔值

我使用了
作为
AnyWrapperType
,但是我得到了一个错误

我也从我知道自己做错了什么但能找到出路的地方开始

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

    if (standard != null && (!standard.isEmpty())) {
        Hashtable<String, String> temp = new Hashtable<>();
        temp.put(Appconstants.Col_studentinfo_S_Class,
                AvailableClass.getValueByName(standard));
        paramTocol.put("standard", temp);
    }
    if (section != null && (!section.isEmpty())) {
        Hashtable<String, String> temp = new Hashtable<>();
        temp.put(Appconstants.Col_studentinfo_S_Section, section);

        paramTocol.put("section", temp);
    }
Hashtable paramTocol=new Hashtable();
if(standard!=null&(!standard.isEmpty()){
Hashtable temp=新的Hashtable();
临时输入(Appconstants.Col\u studentinfo\u S\u类,
AvailableClass.getValueByName(标准));
参数输入(“标准”,温度);
}
if(section!=null&(!section.isEmpty()){
Hashtable temp=新的Hashtable();
温度输入(Appconstants.Col_studentinfo部分,部分);
参数输入(“区段”,温度);
}

这里,
标准的实际值是数据库中的整数
,对应于
部分的值是char
。我得到了所有这些值作为字符串,我需要将它们存储在哈希表中,所以我需要一些原始哈希表来保存所有这些值。没有一个类型是用户定义的

我认为您可以将
AnyWrapperType
设置为
对象
。因为java中的所有类都是Object的直接或间接子类,所以您可以将类型设置为Object,而不是设置泛型类型。 当您需要获取该元素时,应执行
类型转换

HashTable<String, HashTable<String, Object>>
哈希表

现在还不清楚您现有的代码是什么样子,或者您以后试图对该表做什么(或者为什么不使用
HashMap
),我已经添加了更多的描述,我希望这能解决我的问题。实际上,我们不知道涉及的任何类型。什么是
Appconstants.Col\u studentinfo\u s\u Section
例如?
Appconstants.Col\u studentinfo\u s\u Section
是一个与数据库中的列名相对应的字符串。因此,示例代码中的所有内容都与字符串有关-包装类型来自何处?如果你能展示一个简短但完整的程序(一个控制台应用程序),它将真正帮助你解决问题。请阅读