add Vectors - Java java.lang

Java examples for java.lang:Math Matrix

Description

add Vectors

Demo Code


//package com.java2s;

public class Main {
    public static float[] addVectors(float[] vec1, float[] vec2) {
        if (vec1.length != vec2.length) {
            return null;
        }//from  w w w  .ja v a  2 s .  c  om

        float[] returnFloat = new float[vec1.length];

        for (int i = 0; i < vec1.length; i++) {
            returnFloat[i] = vec1[i] + vec2[i];
        }

        return returnFloat;
    }
}

Related Tutorials