用lambda表达式求数组元素的最大值

Question:使用Supplier接口作为方法参数类型,通过lambda表达式求出int数组中的最大数

public class DemoTest{
	public ststic int getmax(Supplier  sup){
		return sup.get();
	}
	public ststic void main(String [] args){
	int [] arr=new [5];
	int value=getmax(()->{
		int max=arr[0];
		for(int i:arr){
			if(max

用lambda表达式求数组元素的最大值_第1张图片

你可能感兴趣的:(Suppler,lambda)