彼らは以下のとおりです。
私はハッシュマップの値にサイコロを転がした後、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>)
私のコードは次のとおりです。
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]);
お手伝いありがとう
Mureinik:
あなたは、一連の保存したい場合は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);