Hi,
I am currently working on a Priority Queue that enqueues an element and a priority. My getHighest method works but it will not allow me to actually print out the priority and I continue to get an -
Exception in thread "main" java.lang.ClassCastException: UnsortedList$Link cannot be cast to java.lang.String
at Main.main(Main.java:82)
error message. My method in my Queue class is
Also my tester class contains this line of code that I am using to try to print the priority without actually dequeueing
it completely from the queue.
I am currently working on a Priority Queue that enqueues an element and a priority. My getHighest method works but it will not allow me to actually print out the priority and I continue to get an -
Exception in thread "main" java.lang.ClassCastException: UnsortedList$Link cannot be cast to java.lang.String
at Main.main(Main.java:82)
error message. My method in my Queue class is
public E getHighest() throws EmptyQueueException {
if (isEmpty()){
throw new EmptyQueueException("Empty Queue");
}
else{
int maximum_Size = 100;
Link<E> front = null;
for(Link<E> element: List){
if (element.getPriority() < maximum_Size){
maximum_Size = element.getPriority();
front = element;
}
}
return (E) front;
}
}
}
Also my tester class contains this line of code that I am using to try to print the priority without actually dequeueing
it completely from the queue.
try {
System.out.println("The highest priority is " + x.getHighest());}
catch (EmptyQueueException e)
{
System.out.println("Error, no Strings");
}