A question referenced by the Java8 method: why can an abstract method of an interface be referenced?

the code is as follows

public static void main(String[] args) {
    List<String> list = new ArrayList<>();
    list.add("hello");
    list.add("alex");
    list.add("front");
    BiConsumer<List<String>, String> v = List::add;
    System.out.println(v == null);
    v.accept(list, "ddd");
    System.out.println(list);
}

IDE does not report an error for IDEA, and is running normally.
my question is why the following sentence is correct:

BiConsumer<List<String>, String> v = List::add;

List is an interface, the add method has only a declaration and no specific implementation, and its front obviously does not match the accept of the BiConsumer interface.
BiConsumer interface definition:

@FunctionalInterface
public interface BiConsumer<T, U> {
    void accept(T t, U u);
    
    default BiConsumer<T, U> andThen(BiConsumer<? super T, ? super U> after) {
        Objects.requireNonNull(after);

        return (l, r) -> {
            accept(l, r);
            after.accept(l, r);
        };
    }
}

method signature of List::add:

boolean add(E e);

-
in addition, if I remove the generics, I will report an error as follows:

BiConsumer v = List::add;

Why is that?

Sep.16,2021

https://stackoverflow.com/que.

that's just a method reference, which you can think of as an abbreviation. You will understand when you expand it into an lambda expression.

Post the statement of
BiConsumer , and take a look at stream and lambda

of java.
Menu