1、使用Supplier接口的代码:
import java.util.function.Supplier;
public class SupplierTest {
public static int getMax(Supplier<Integer> sup){
// sup 只有一个 get 方法,只需要重写这个方法
return sup.get();
}
public static void main(String[] args) {
int arr[] = {
3,5,9,