On line 599 this code is instantiating the AbstractSet class. How is this possible?
Via an anonymous inner class. It's creating a concrete (but unnamed) subclass of AbstractSet
. You can do the same for interfaces. For example:
Runnable runnable = new Runnable() {
@Override public void run() {
// Put some code in here...
}
};
I'm assuming that the public methods in lines 601, 606, 612, 617 and 622 are anonymous inner classes?
No, the whole class is the anonymous inner class. These are implementing the abstract methods of AbstractSet
.
I suggest you read the Java tutorial page on anonymous classes.