Question: Hi, my code won't execute, seems like something happened on line 29 according to the bottom highlighted part. Can you please help me find out

 Hi, my code won't execute, seems like something happened on line

Hi, my code won't execute, seems like something happened on line 29 according to the bottom highlighted part.

Can you please help me find out what was happening?

Thank you!

Content of the input text file:

it was the best of times it was the worst of times it was the age of wisdom it was the age of foolishness it was the epoch of belief it was the epoch of incredulity it was the season of light it was the season of darkness it was the spring of hope it was the winter of despair

Code File Edit Selection View Go Run Terminal Window Help 65% 9 Sat Jan 8 23:12 PriorityQueueTost java - JAVA th Priority * 1 x DataStructure Pror youeue estava > PriorttyQueue Test main(Stringit 8 import java.util.Hop. Entry: 9 import java, util, PriorityCueue; 10 public class Priority Queue Test { Run Datug 12 public static void main(Stringa args) throws FileNotFoundException 13 NupString. Integer wordsFrequency - mem HashMap O: 14 Scanner scanner - HC Scanner(new File("DataStructure/tinyTable.txt")); 15 while (scanner, hasNext) { 16 String word - scanner.next; 17 if Chords Frequency containskeycord)) { 18 words Frequency-put(word, words Frequency.get(word) + 1); 19 28 else { 21 wards Frequency.put(word, 1); 22 3 23 } 24 25 Comparator EntryString. Integer>> COTP = C, D) -> Q.getValue - 1. getValue: ( 26 PriorityQueue EntryString. Integer>> p4 - mem PriorityQueuroO; for (EntryString. Integer entry : words Frequency, entrySet) [ 28 if (pg.Sizeo 0) { 22 pq.pollo; 33 pq.offerCentry) 34 } 35 36 37 while Cipqisimpty() { 38 EntryString. Integer entry = p.pollo: 39 System.out.printlncertry); 46 3 41 42 43 ) 44 } 45 PROBLEWS OJITELT DIDUG CONSOLE TERMINAL F. PERE CAT + T 8 at java.use/java.util. Priorityeve.uffer(PriorityOuese.java:330) at java.base/java.util. Priorityoueue.add(PriorityQueue.java:311) at Datastructure. Priorityqueue Test.rain Priorityqueue Test.java:29) 201801ChangdeacBook Air JAVA * cd /users/qc1/Desktop/Udemy/JAVA /usr/bin/env /Library/Java/JavavirtualMachines/jdk-15.8.2.dk/Contents/Hone/bin/java : Show coccoctailsInException essages -cp /Users/461/Library/Application Support/Code/User/wor kspaceStorage/3215208aBac2518496968e7206703487/redhat.java/jdt_ws/JAVA_21704b8d/hin" DataStructure.Priority.euetes Exception in threar "rain" java.lang.ClassCastException: class java.util.Hash Maplode cannot be cast to class java.lang.Corparable java.util.Hashwaplode and java.lang.Comparable are in nedule java.base of loacer 'bootstrap'l at java.base/java.util. Priority.eue.si fuborparable(PriorityOuese.java:623) at java.base/java.util. PriorityOueue. siftUp (PriorityOuese.java:639 at java.base/java.util. PriorityOueue.offer(PriorityQueue.java:330) at Datastructure. Priorityqueue Test.rain Prioratyqueue Test.java:29) qc11ChangdeacBook Air JAVAN Ln ON In 29. 25 Spaces: 2 UTF-B LE JW JW5E-16 Sool FC - Jawa JwaSE- F

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!