title: Priority Queue for HashMap Object in Java
body: <p>I have created a HashMap object which stores a String as key and corresponding value as int. Now I want to have  a Priority Queue which have all the String present in HashMap object with value as reference for assigning priorities. I have written the following code</p>
  
  <pre><code>public class URIQueue {
  
        private HashMap&lt;String,Integer&gt; CopyQURI;
        private PriorityQueue&lt;String&gt; QURI;
  
        public class TComparator&lt;String&gt; {
           public int compareTo(String s1, String s2) {
              if (CopyQURI.get(s2) - CopyQURI.get(s1) &gt;= 0) {
                 return 1;
              } else {
                 return 0;
              }
           }
        }
  
        public URIQueue() {
           CopyQURI=new HashMap&lt;&gt;(100);
           TComparator&lt;String&gt; tc=new TComparator&lt;&gt;();
           QURI=new PriorityQueue&lt;&gt;(100, tc); //Line x
        }
   }
  </code></pre>
  
  <p>Line x is showing error cannot infer type argument for priority queue. Please guide me what mistake I have done.</p>