Since java interfaces cannot be instantiated, how could interfaces be class members and be instantiate by class constructors etc.
jdk code:
public class PriorityQueue<E> extends AbstractQueue<E>
implements java.io.Serializable {
private final Comparator<? super E> comparator;
...
}
and user code:
PriorityQueue<Point> pq = new PriorityQueue<Point>(1005,new Comparator<Point>(){
public int compare(Point p1,Point p2){
...
}
});
The above usage of PriorityQueue is valid (just for example). And the Comparator in the class PriorityQueue is actually an interface. So the interface become a member of class?! Besides, when instantiate the PriorityQueue, the interface is instantiated, which is so mysterious.