将数组乘以适当的常数。
//package com.nowjava; /** from N o w J a v a . c o m**/ public class Main { /** * Multiplies the array by a constant factor in place. * @param input * @param factor * @return */ public static void multiply(double[] input, double factor) { for (int i = 0; i < input.length; i++) { input[i] = input[i] * factor; } } /** * Multiplies each value of the first array with the corresponding * value of the second one. */ public static double[] multiply(double[] first, double[] second) { if (first.length != second.length) { throw new IllegalArgumentException("Dimensions don't match! "/** n o w j a v a . c o m - 时代Java 提 供 **/ + first.length + " != " + second.length); } double[] result = new