Method reference:
The method reference returns the implementation of the interface.
private static <T> Iterable<T> itToIterable(Stream<T> stream) { return stream::iterator; //编译通过此处返回的是Iterable }
Method call:
Method call returns the return value of the method.
private static <T> Iterable<T> itToIterablePro(Stream<T> stream) { return stream.iterator(); //编译失败此处返回的是iterator }
Recommended tutorial: Java tutorial
The above is the detailed content of The difference between method reference and method call in java. For more information, please follow other related articles on the PHP Chinese website!