无法使用键从Java HashMap获取值

无法使用键从Java HashMap获取值,java,android,exception,hashmap,Java,Android,Exception,Hashmap,这是我的HashMap对象: public static Map<String, Integer> kart = new HashMap<String, Integer>(); String pIndex="Any Index Value"; int value=anyIntegerValue; 检查索引并获取值的代码: String inKart = "Product is not in Kart"; if(Globals.kart.containsKey(pInde

这是我的HashMap对象:

public static Map<String, Integer> kart = new HashMap<String, Integer>();
String pIndex="Any Index Value";
int value=anyIntegerValue;
检查索引并获取值的代码:

String inKart = "Product is not in Kart";
if(Globals.kart.containsKey(pIndex)){
    int count = Globals.kart.get(pIndex);
    inKart = "Product is in Kart " + count;
}
System.out.print(inKart);
它正在成功地检查密钥,但是当它试图根据密钥从kart获取值时,它抛出一个异常,String reource ID#0x1

No package identifier when getting value for resource number 0x00000001
android.content.res.Resources$NotFoundException: String resource ID #0x1
所有的例子都表明我可以通过使用字符串键来获取值,但它对我不起作用。我做错了什么

编辑:

我编辑了一些键入错误,并将一些变量名重新写入了我在原始代码中编写的内容

请注意,如果我使用containsKey(pIndex)检查密钥,它不会给出任何错误。异常仅在kart.get(pIndex)行中发生

No package identifier when getting value for resource number 0x00000001
android.content.res.Resources$NotFoundException: String resource ID #0x1

一些评论提到该错误与HashMap无关。如果是这种情况,那么请解释为什么此代码仅在Android中的特定行引发异常。

HashMap返回一个整数值,并且在TextView中被伪造为整数或字符。所以我用字符串显式地输入它,一切都很好

再次感谢


Ram Ram

kart
应该与
Globals相同。kart
?资源的方法调用在哪里?异常与问题中的HashMap和代码片段无关。给定的错误与映射完全无关。这里有一个关于该特定错误的stackoverflow问题。