java:如何将值元素放入hashmap值数组?

java:如何将值元素放入hashmap值数组?,java,hashmap,Java,Hashmap,在对hashmap的值掷骰子之后,我试图输入int结果。IDE在此行上显示错误: map.put(1, diceRoll); 其解释是: The method put(Integer, ArrayList<Integer>[]) in the type Map<Integer,ArrayList<Integer>[]> is not applicable for the arguments (int, ArrayList<Integer>) 类

在对hashmap的值掷骰子之后,我试图输入int结果。IDE在此行上显示错误:

map.put(1, diceRoll);
其解释是:

The method put(Integer, ArrayList<Integer>[]) in the type Map<Integer,ArrayList<Integer>[]> is not applicable for the arguments (int, ArrayList<Integer>)
类型映射中的方法put(Integer,ArrayList[])不适用于参数(int,ArrayList)
我的代码是:

Map<Integer, ArrayList<Integer>[]> map = new HashMap<Integer, ArrayList<Integer>[]>();
ArrayList<Integer> diceRoll= new ArrayList<Integer>();
Dice dice = new Dice();
diceRoll.add(dice.getLastRoll());

map.put(1, diceRoll); 
ArrayList<Integer>[] integers = map.get(1);
System.out.print(integers[0]);
Map Map=newhashmap();
ArrayList dicerll=新的ArrayList();
骰子=新骰子();
添加(dice.getLastRoll());
地图放置(1,掷骰子);
ArrayList[]整数=map.get(1);
系统输出打印(整数[0]);

感谢您的帮助

如果您想存储一系列的
int
s,您不需要列表数组,只需要一个列表:

Map<Integer, List<Integer>> map = new HashMap<>();
List<Integer> diceRoll = new ArrayList<>();
Dice dice = new Dice();
diceRoll.add(dice.getLastRoll());

map.put(1, diceRoll); 
Map Map=newhashmap();
List diceRoll=新建ArrayList();
骰子=新骰子();
添加(dice.getLastRoll());
地图放置(1,掷骰子);

@Jie您是否如我的回答所示更改了地图的声明?非常抱歉!我没有从
Map
中删除[]。它现在运行得很好。非常感谢你的帮助!