给定一个int数组,生产出最大数。
import java.util.Spliterator; import java.util.function.Supplier; public class demo_getmax { public static int getmax(Integer[] in, Supplier<Integer> sup) { return sup.get(); } public static void main(String[] args) { Integer[] in = {1, 4, 2, 7, 9, 3,-20,24}; int max_ = getmax(in, () -> { int max = in[0]; for (Integer integer : in) { if (integer > max) { max = integer; } } return max; }); System.out.println(max_); } }