分类:N07_Java
package com.wpf.java;
import java.util.function.Supplier;
public class SupplierLambda {
public static void main(String args) {
int arr = {2, 4, 5, 56, 22, 234};
int max = getMax(()->{
int temp = arr[0];
for (int i =1; i < arr.length; i++){
if(arr[i]>temp){
temp = arr[i];
}
}
return temp;
});
System.out.println("数组中的最小值是"+max);
}
public static int getMax(Supplier sup) {
return sup.get();
}
}