java快速寻找一个数组的最大值或最小值, min, max,三种方法

		int[] prices = {7,1,5,3,6,4};
		//求出最大值的几种方式
		int max = Arrays.stream(prices).max().getAsInt();
		System.out.println(max);
		int max1 = Collections.max(Arrays.asList(ArrayUtils.toObject(prices)));
		System.out.println(max1);
		
		Arrays.sort(prices);
		System.out.println(prices[prices.length - 1]);
posted @ 2021-12-20 09:11  卡卡罗特琪琪  阅读(843)  评论(0编辑  收藏  举报