Java String Sub String substract(int[] array1, int[] array2)

Here you can find the source of substract(int[] array1, int[] array2)

Description

Returns the element-wise substraction of two arrays.

License

Open Source License

Parameter

Parameter Description
array1 Input array 1
array2 Input array 2

Return

A new array with the element-wise subtraction

Declaration

public static int[] substract(int[] array1, int[] array2) 

Method Source Code

//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;
    }
}

Related

  1. substr(String substr1, String substr2)
  2. substr(String what, int begin, int end)
  3. substr(StringBuffer buf)
  4. substract(double[] a, double[] b)
  5. substract(double[] a, double[] b)
  6. substract(Number n1, Number n2)
  7. substraction2(double[] a, double[] b)
  8. substractPrefixPostfix(Object obj, String prefix, String suffix)
  9. subStrBeforeDotNotIncludeDot(String str)