下面是我的代码。我很成功添加值地图 但是当试图获得特定键的值,并更新它,然后没有价值越来越Java:地图显示错误:二元运算符的操作数类型错误“+”
收到错误:坏数类型二进制运算符“+”
Map map = new HashMap();
System.out.println("Enter the number :");
int k=sc.nextInt();
System.out.println(map.get(k));
System.out.println("Enter the value:");
int v=sc.nextInt();
map.put(k, map.get(k)+v); //getting error here: bad operand type for binary operator "+"
+1参考相关的Java版本 –
@CahitGungor谢谢! – geoand