提示:您可在线编辑运行本教程的实例 - 运行实例,去试试!
返回数组的最小值。
//package com.nowjava; /* 来自 *时代Java公众号*/ public class Main { public static void main(String[] argv) throws Exception { double[] v = new double[] { 34.45, 35.45, 36.67, 37.78, 37.0000, 37.1234, 67.2344, 68.34534, 69.87700 }; System.out.println(min(v)); } /** * Returns the minimum of an array. */ public static double min(double[] v) { double min = v[0]; for (int i = 1; i < v.length; i++) { if (min > v[i]) { min = v[i]; } }//N o w J a v a . c o m - 时 代 Java 提供 return (min); } /** * Returns the minimum of an array. */ public static double min(double[][] v) { double min = min(v[0]); for (int i = 1; i < v.length; i++) { if (min > min(v[i])) { min = min(v[i]); } } return (min); } /** * Returns the minimum of an array. */ public static int min(int[] v) { int min = v[0]; for (int i = 1; i < v.length; i++) { if (min > v[i]) { min = v[i]; } } return (min); } /** * Returns the minimum of an array. */ public