System.out.println("a".compareTo("ab")); prints out -1.
Note: The PriorityQueue adds and removes based on Comparable; however, if you iterate of the PriorityQueue you may not get the results that you expect. The iterator does not necessarilly go through the elements in the order of their Priority. In other words, if you want to see how the elements are added and removed, do not rely on an iterator. Use the remove() method of the priorityQueue class as is shown in the example code below. Priority Queue Demo
import java.util.*;
public class PriorityQueueDemo {
PriorityQueue<String> stringQueue;
public static void main(String[] args){
|
Output a ab abc abcd |
Write a program that includes at least two classes. One is a Patient class. The other should be a PriorityQueue of Patients.