Method reference:
The method reference returns the implementation of the interface.
private staticIterable itToIterable(Stream stream) { return stream::iterator; //编译通过此处返回的是Iterable }
Method call:
Method call returns the return value of the method.
private staticIterable itToIterablePro(Stream 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!