Cannot add (int, double) pair to HashMap <Integer, Double>
I am working on a Java project right now and I have a class that I created called DistanceQueue. His signature is set
public class DistanceQueue<Integer> extends PriorityQueue<Integer> There is a method in this class
public boolean add(int v) which adds a key-value pair (v, Double.MAX_VALUE) to the HashMap called the distance, which is in the DistanceQueue class. However inside add (int v) when I type
distances.put(v, Double.MAX_VALUE); I get the following error:
DistanceQueue.java:98: error: no suitable method found for put(int,double) distances.put(v, Double.MAX_VALUE); ^ method HashMap.put(Integer,Double) is not applicable (actual argument int cannot be converted to Integer by method invocation conversion) where Integer is a type-variable: Integer extends Object declared in class ShortestPaths.DistanceQueue 1 error Does anyone know why I am getting this error? I thought Java would automatically convert between int and Integer for you. Is there an easy way I can fix this?
Thanks!
+5