How to add a single map entry to priority queue
At the moment I have to add the whole map, as shown in the last line. PriorityQueue<Map.Entry<String, Integer>> sortedCells = new PriorityQueue<Map.Entry<String, Integer>>(3, new mem()); Map<String,Integer> pn = new HashMap<String,Integer>(); pn.put("hello", 1); pn.put("bye", 3); pn.put("goodbye", 8); sortedCells.addAll(pn.entrySet()); What if I just wanted to add ("word" 5) If i do sortedCells.add("word",5) I get an argument error. How can I add a single element? You should add a Map.Entry object and not just ("word", 5) because the generic type of your priority queue is Map.Entry<String,