Question: Hi this is a question about the PriorityQueue in Java. I have import java.util.PriorityQueue at the beginning of the code, why do I still get

 Hi this is a question about the PriorityQueue in Java. Ihave import java.util.PriorityQueue at the beginning of the code, why do I

Hi this is a question about the PriorityQueue in Java.

I have import java.util.PriorityQueue at the beginning of the code, why do I still get a error on line 27?

Thank you!

Code File Edit Selection View Go Run Terminal Window Help 68% 9 Sat Jan 8 21:49 2 0 PriorityQueue java JAVA PriorityQHjU? X DataStructure > PrerryOutu Jawa. package DutoStructure; import java.io.File; import java.io.FileNotFoundException; inport java.util. Hap; 5 import java.util.comparator; 6 import java.util.Hush Map; import java.util.Scanner; 8 port java.util.Hop. Entry: 9 import java.util.Priorityqueue: 761 11 public class Priority Queue { Run Doug 12 public static void main(Stringa ang) throws FileNotFoundException { 13 NopString. Integer wordsfrequency - ner HushMoO; 14 Scanner scanner - now Scanner(new File("DataStructure/tinylable.txt); 15 while (scanner, hasNext() { 16 String word - scanner.next(); 17 if (words Frequency containskey(word)) { 18 words Frequency.put(word, words Frequency.get(word) + 1); 19 28 else { 21 words frequency.put(word, 1); ) 23 } 24 25 Comparator Entry String. Integer >> Comp - Co, ) -> 2.getValue - 5. getValue: 26 PriorityQueue> pq = new PriorityQueue; 28 29 30 List> list = new ArrayList (wordsFrequency.entrySeto); 31 list.sort(a, b) -> b.getValue - 0.getValue(); list.forEach(e -> System.out.println(e.getKey() + " appears ' + e.getValue() + " times"); ( + 33 34 // for (EntryString, Integer entry wordsFrequency antySeto 35 wwwwwwwwwwwwwwwwwwwwww // + System.out.printlncentry.getkeroppers + entry.getValue + " cimes."); + .) 36 27 ) 38 POSLIMS 37 CUTPUT DEBUS CONSOLE TERMINAL Priorityqucuc.java:26: crror: not a statenent import java.util. PriorityQueue; 2 errors @ Done] exited with code-1 in 6.689 seconds 54 3002 LA 8. Cal 32 Space: 2 UTF-B LF JW JWSE-15 Sool 0 - 16 Code File Edit Selection View Go Run Terminal Window Help 68% 9 Sat Jan 8 21:50 0 PriorityQueue java JAVA 2 Priority UHUR 7 X DataStructure > PrerryOutu Jawa. package DutoStructure; import java.io.File; import java.io.FileNotFoundException; inport java.util. Hap; 5 import java.util.Comparator; 6 import java.util.Hush Map; import java.util.Scanner; 8 port java.util. Map. Entry: . . 9 import java.util.Priorityqueue: 761 11 public class PriorityQueue ! Run Debug 12 public static void main(Stringa ang) throws FileNotFoundException { 13 NopString. Integer wordsfrequency - ner HushMoO; 14 Scanner scanner - new Scanner(new File("DataStructure/tinylable.txt); 15 while (scanner, hasNext() { 16 String word - scanner.next(); 17 if (words Frequency.containskeycord)) { 18 words Frequency-put (word, words Frequency.get(word) + 1); 19 28 else { 21 mords Frequenty.put(word, 1); 22 23 Datastructure, PriorityQueue 24 25 The type PriorityQueue is not generic; it cannot be puruneterized with arguments Map. EntryString, Integer>> Java( 16777740) 26 View Problem he quick wes wie 27 PriorityQueue Entry String. Integer>> pq = new PriorityQueuecO 28 29 30 List> list = new ArrayList (wordsFrequency.entrySeto); 31 list.sort(a, b) -> b.getValue - 0.getValue(); list.forrache -> System.out.printlnce.getKey + " appears ' + e.getValue + " times"); () + 33 34 // for (EntryString, Integer entry wordsFrequency antySeto 35 wwwwwwwwwwwwwwwwwwwwww // + System.out.printlncentry.getkeroppers + entry.getValue + " cimes."); + .) 36 27 ) 38 POSLIMS 37 CUTPUT DEBUS CONSOLE TERMINAL Priorityqucuc.java:26: crror: not a statenent import java.util. PriorityQueue; 2 errors @ Done] exited with code-1 in 6.689 seconds 54 3002 LA 8. Cal 32 Space: 2 UTF-B LF JW JWSE-15 Sool 0 - 16

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!