3 ms·
Iterators are an interesting addition to Java 8, but a bigger change is what they had to do to enable iterators to exist. What they did was allow interfaces to
by btilly 11y ago
Iterators are an interesting addition to Java 8, but a bigger change is what they had to do to enable iterators to exist.
What they did was allow interfaces to provide default methods. They then added stream() and parallelStream() default methods to the Collection interface to generate streams and start all of the iterator goodness.
The result is that in Java 8, an interface now behaves like a Ruby mixin. It is a way to do multiple inheritance in a language that officially does single inheritance.
I'm sure there will be some disasters before the Java community settles on best practices for this feature. :-)