@FunctionalInterface
public interface Streamable<T> extends Iterable<T>, Supplier<Stream<T>>
I was exploring the Streamable Interface and the first method that I came across was the empty()
method that has the following definition.
static <T> Streamable<T> empty() {
return Collections::emptyIterator;
}
Collections::emptyIterator
returns the Iterator<T>
but the return type of this method is Streamable<T>
. Streamble extends Iterable and Supplier and not Iterator interface.
I didn't understand how is that working fine. Can someone please help me in understanding this?
I'm just failing in understanding the concept here. I wanted to know how is this working as I'm aware of how Inheritance works, but I'm unable to figure it out. I think I'm missing something here.