I have encountered the following Java syntax that I don\'t recognize.
This part is fine:
public abstract class Stream implements Iterator
This is providing an inline (anonymous) subclass of the Stream
class.
Functionally, it is the same as:
public NewClass extends Stream {
public Integer next() {
return 1;
}
}
and
void someMethodInAnotherClass {
Stream stream = new NewClass();
}
but as this class definition isn't used outside the method body, you can define it as anonymous.