title: PriorityQueue and Comparator
body: <p>I am trying to get from localNodes the Node who has the minimum distance from the hashmap distance. the problem when am changing any value in the distance hashmap the queue is not reordered i think the problem is because  i am implemting the comparator interface like that which will be as an inner class and enforce me to declare the hashmap as final.
  is there any different method.</p>
  
  <pre><code>    final HashMap&lt;Node, Double&gt; distance = new HashMap&lt;&gt;();
      PriorityQueue&lt;Node&gt; localNodes = new PriorityQueue&lt;&gt;(10,
              new Comparator() {
  
                  @Override
                  public int compare(Object o1, Object o2) {
                      return distance.get((Node)o2).compareTo(distance.get((Node)o2) );
                  }
              });
  </code></pre>