嗨,我在运行此代码时出错
Map<String, Integer> map = new TreeMap<String, Integer>();//Already populated
public ArrayList<Map<String, Integer>> storage(){
for (String getCharacter : map.keySet()){
String convertBinGrp;
**Integer binGroups = Integer.valueOf(getCharacter);**
if ( binGroups>=0 && binGroups<= 32){
convertBinGrp = Long.toString(binGroups);
binInsideList.get(convertBinGrp);
Integer getVal = getCharacter.getValue();
binInsideList.put(convertBinGrp, getVal);
}
}
Run Code Online (Sandbox Code Playgroud)
错误消息:线程"main"中的异常java.lang.NumberFormatException:对于输入字符串:""
指示的错误是Integer binGroups = Integer.valueof(getCharacter) cast.我已经尝试过使用long和double来确保它的大小更大,因为我理解它从Map获取的String值.但还有其他方法可以解决这个问题吗?我想将String转换为数值,以便我可以将它放入正确的bin或组中.谢谢