I am running into a casting issue. I cannot seem to figure out the problem since everything appears to be in order. I understand that to explicitly cast from the Double wrapper class to the Integer wrapper class it can be done however, my compiler does not recognize it. Am I missing something obvious?
The exact error I'm getting is : "Inconvertible types; cannot cast 'double' to 'java.lang.Integer'.
Thanks for your help!
private HashMap<String, Integer> shortestPath(String currentVertex, Set<String> visited) {
double tempVal = Double.POSITIVE_INFINITY;
String lowestVertex = "";
Map<String, Integer> adjacentVertex = this.getAdjacentVertices(currentVertex);
HashMap<String, Integer> lowestCost = new HashMap<String, Integer>();
for(String adjacentNames : adjacentVertex.keySet()) {
Integer vertexCost = adjacencyMap.get(currentVertex).get(adjacentNames);
if(!visited.contains(adjacentNames) && (vertexCost < tempVal)) {
lowestVertex = adjacentNames;
tempVal = vertexCost;
}
}
lowestCost.put(lowestVertex, (Integer)tempVal);
return lowestCost;
}