I am writing a program here that takes two int[] arrays and subtracts each element from each other and stores the result in a new array.
this sounds pretty sound and i know my math is right seeing as its simple subtraction..
my method is here,
public int[] diff(int[] nums1, int[] nums2)
    {
        int[] diffArray = new int [nums1.length];
        int tempValue = 0;
        int tempValue2 = 0;
        int subtract = 0;
        if (nums1.length != nums2.length)
        {
            diffArray = new int[0];
        }
        else
        {
            for (int i = 0; i < nums1.length && i < nums2.length; ++i)
            {
                tempValue = nums1[i];
                tempValue2 = nums2[i];
                System.out.println("temp value 1: " + tempValue); //just me trying to debug
                System.out.println("temp value 2: " + tempValue2); //just me trying to debug
                subtract = tempValue2 - tempValue;
                System.out.println("Subtracted :" + subtract); //just me trying to debug
                diffArray[i] = subtract;
            }
        }
        return diffArray;
    }
to test this i wrote a couple small pieces of code in my driver class.
The problem is, i made those 3 debug print statements in my for loop to see if i had the right numbers and everything is correct it just seems like its not storing it in diffArray?
for example,
   //Array of 1 element each : r(0)
            givenArray = new int[] {4};
            givenArray2 = new int[] {4};
            diffValue = srvObj.diff(givenArray, givenArray2);
            result = (diffValue == new int[] {0}) ? PASS : FAIL;
            System.out.println(testNum + ": " + result);
            ++testNum;
   //Array of multi-elements each that are diff : r({6, 10, 37})
            givenArray = new int[] {4, 5, 3};
            givenArray2 = new int[] {10, 15, 30};
            diffValue = srvObj.diff(givenArray, givenArray2);
            result = (diffValue == new int[] {6, 10, 37}) ? PASS : FAIL;
            System.out.println(testNum + ": " + result);
            ++testNum; 
note : i am subtracting array2 from array1 not the other way.
however i keep getting FAIL every time? i can see in my print statements its done the math for each element
Surely there must be a problem when i try to give diffArray[i] the resulted subtraction?
 
     
     
     
    