Here you can find the source of substract(int[] array1, int[] array2)
Parameter | Description |
---|---|
array1 | Input array 1 |
array2 | Input array 2 |
public static int[] substract(int[] array1, int[] array2)
//package com.java2s; /******************************************************************************* * Copyright (c) 2016 Pablo Pavon-Marino. * All rights reserved. This program and the accompanying materials * are made available under the terms of the GNU Lesser Public License v2.1 * which accompanies this distribution, and is available at * http://www.gnu.org/licenses/lgpl.html * * Contributors://from w w w . j a v a 2 s. c om * Pablo Pavon-Marino - Jose-Luis Izquierdo-Zaragoza, up to version 0.3.1 * Pablo Pavon-Marino - from version 0.4.0 onwards ******************************************************************************/ public class Main { /** * Returns the element-wise substraction of two arrays. * * @param array1 Input array 1 * @param array2 Input array 2 * @return A new array with the element-wise subtraction * */ public static int[] substract(int[] array1, int[] array2) { int[] out = new int[array1.length]; for (int i = 0; i < out.length; i++) out[i] = array1[i] - array2[i]; return out; } }