I am trying to create an array of HashMaps within a class and then retrieve a hashmap from the array for calculation purposes. Here is my code:
HashMap<String, Integer>[] boardPopulation= (HashMap<String, Integer>[]) new HashMap[populationSize];
for(int i=0; i < populationSize; i++){
generateQueens();
boardPopulation[i] = queenMap;
}
for(int i=0; i < populationSize; i++){
queenMap = boardPopulation[i];
printBoard();
}
When I compile I get two issues:
- Board.java uses unchecked or unsafe operations, recompile with -Xlint:unchecked.
- When I compile with "Xlint:unchecked" I get
Warning: [unchecked] unchecked cast HashMap[] boardPop.......(same as line 1 of above code)
required: HashMap[] found: HashMap[]
Please help me ! :D
Ideally I would like to not have to use Xlint unchecked, but ultimately I really just need to be able to retrive a HashMap from the list and assign it to queenMap so I can do calculations within the class.
Thankyou