package collection;
import java.util.Arrays;
import java.util.PriorityQueue;
public class Exercise20_12 {
public static void main(String[] args) throws Exception {
MyPriorityQueue<String> queue1 = new MyPriorityQueue<>();
queue1.addAll(Arrays.asList("George", "Jim", "John", "Blake", "Kevin", "Michael"));
System.out.println(queue1);
MyPriorityQueue<String> queue2 = (MyPriorityQueue<String>)(queue1.clone());
System.out.println(queue2);
System.out.println("queue1.equals(queue2) = " + queue1.equals(queue2));
}
}
class MyPriorityQueue<E> extends PriorityQueue<E> implements Cloneable {
@Override
protected Object clone() throws CloneNotSupportedException {
try {
return super.clone();
} catch (CloneNotSupportedException ex) {
return null;
}
}
}