Hi I am getting an error while trying to use PropertyQueue with java. I am a little unfamiliar with java and would appreciate getting a little bit of explanation with this error! Here is how my code look like roughly:
import java.util.*;
import java.io.*;
class Lecture{
public Lecture(Strings){
...
}
//Then some getter and setter and function
}
class Room{
Vector<Lecture> setLecture = new Vector<Lecture>();
int end = 1;
public void change_end(int c){
end = end +c;
}
public void add_lecture(Lecture l){
setLecture.add(l);
}
}
public class interval_partioning{
public static void main (String[] args) {
// create priority queue
PriorityQueue <Room> classrooms = new PriorityQueue <Room> () ;
Room classroom1= new Room();
Room classroom2= new Room();
classrooms.add(classroom1);
classrooms.add(classroom2);
}
}
here is the error I get at this line : classrooms.add(classroom1);
Exception in thread "main" java.lang.ClassCastException: class Room cannot be cast to class java.lang.Comparable (Room is in unnamed module of loader 'app'; java.lang.Comparable is in module java.base of loader 'bootstrap')
What does it mean and how to fix it!
Thank you!

Vector. It's usage is discouraged since java 1.2.Roomdoesn't implementComparableinterface. SoPriorityQueuehas no idea how to sort items.