Write QueueSets: read two lines of words and put each line in a PriorityQueue<String>. Print:
- the first queue as it is stored (
toString) and then in priority order — they differ! - the second queue in priority order;
- their union (no duplicates), their difference (first without second) and their intersection, each as a new priority queue, in priority order;
- the size and the head of the first queue, to show that it was not modified.
Write a method inOrder(PriorityQueue<String>) that returns the elements in priority order without emptying the queue it receives. For the input
George Jim John Blake Kevin Michael
George Katie Kevin Michelle Ryan
the program prints
First, as stored: [Blake, George, John, Jim, Kevin, Michael]
First, in priority order: [Blake, George, Jim, John, Kevin, Michael]
Second, in priority order: [George, Katie, Kevin, Michelle, Ryan]
Union: [Blake, George, Jim, John, Katie, Kevin, Michael, Michelle, Ryan]
Difference (first without second): [Blake, Jim, John, Michael]
Intersection: [George, Kevin]
First still has 6 element(s); its head is Blake