package _5_22;
import java.util.function.Supplier;
public class InterfaceSupplier {
public static int getMax(Supplier<Integer> sup) {
return sup.get();
}
public static void main(String[] args) {
int[] arr = {80, 10, -20, 101, 75, 17, -30};
int maxValue = getMax(() -> {
int max = arr[0];
for (int i : arr) {
if (i > max) {
max = i;
}
}
return max;
});
System.out.println(maxValue);
}
}
903

被折叠的 条评论
为什么被折叠?



