public class MethodReferenceDemo1 {
@FunctionalInterface
interface StringListFormatter {
String format(String delimiter, List list);
}
public static void formatAndPrint(StringListFormatter formatter, String delimiter, List list) {
String formatted = formatter.format(delimiter, list);
System.out.println(formatted);
}
public static void main(String[] args) {
List names = Arrays.asList("Don", "King", "Kong");
formatAndPrint(String::join, ", ", names);
}
}
原文:http://www.cnblogs.com/IcanFixIt/p/4253296.html