As of Java 9, Iterable
is defined as the following (without documentation, for brevity):
public interface Iterable<T> {
Iterator<T> iterator();
default void forEach(Consumer<? super T> action) {
Objects.requireNonNull(action);
for (T t : this) {
action.accept(t);
}
}
default Spliterator<T> spliterator() {
return Spliterators.spliteratorUnknownSize(iterator(), 0);
}
}
As we can see, this interface only contains one abstract method. Because one or more of the methods in this interface utilize the default
keyword, this interface must have been edited since the release of Java 8 (the documentation defines @since 1.8
, but was not included in this question).
For those reasons, why is Iterable
not defined with the @FunctionalInterface
annotation?