title: Find Sum of array passed as variable arguments (varargs) parameter then return result as an array in Java
body: <ol>
  <li>Need to pass array as a variable arguments (varargs)
  ==> consider </li>
  </ol>
  
  <pre><code>double[] array_1 = {1.1, 3.3, 5.5, 7.7, 9.9, 11.11};
  double[] array_2 = {2.222, 4.444, 6.666, 8.888, 10.100, 12.122};
  double[] array_3 = {3.111, 3.222, 3.333, 3.444, 3.555, 3.666};
  .
  .
  .
  
  double[] array_n = {12.444, 12.888, 13.332, 13.776, 14.22, 14.664}
  </code></pre>
  
  <ol start="2">
  <li>Sum all of those n number of arrays</li>
  </ol>
  
  <p>sum_n_arrays = array_1 + array_2 + ... + array_n</p>
  
  <ol start="3">
  <li>Return result as one final array
  ==> sum_of_n_arrays = [x1, x2, x3, x4, x5, x6];</li>
  </ol>
  
  <p>Here's the progress so far...</p>
  
  <p>Add THREE arrays: </p>
  
  <pre><code>public double[] sumThreeArrays(double[] firstArray, double[] secondArray, double[] thirdArray) {
     // check all arrays are not null and of same length
     int length = (firstArray.length == secondArray.length &amp;&amp; secondArray.length==thirdArray.length ) &amp;&amp;
                  (firstArray.length &gt;0 &amp;&amp; secondArray.length &gt;0 &amp;&amp; thirdArray.length &gt;0)
                  ? firstArray.length : -1;
  
     double[] result = new double[length];
     if (length &gt; 0) {
              for (int i=0; i&lt;length; i++) {
                  result[i] = firstArray[i] + secondArray[i] + thirdArray[i];
              }
      }
      System.out.println("Sum of Three Arrays: " + Arrays.toString(result));
      return result;
      }
  </code></pre>
  
  <p>Result ---> Sum of Three Arrays: [6.433, 10.966, 15.499, 20.032, 23.555, 26.898]</p>
  
  <p>Do the same for function that takes multiple n arrays as argument (variable args) then return array sum as final result</p>
  
  <pre><code>public double[] SumMultipleArray(double[] ...arr) {
     //1. pass multiple arrays using var args --&gt; spread operator
  
     //2. check length of each array is same and not NULL
  
    //3. Sum all multiple arrays
          ```
          public double[] sumVarArg(double[] ...arr) {
              int arrayLength;
              double[] result = {0.0, 0.0, 0.0, 0.0, 0.0, 0.0};
              int argsCount = arr.length; // number of arguments passed as an array     
  
          for (double[] d: arr) {
              arrayLength = d.length; // number of element in each array
  
              for (int i=0; i&lt;arrayLength; i++) {
                  result[i] += d[i];
              }
  
          }
          return result;
      }
          ```
  
  
  
  
  
    //4. TO DO (Thinking of using stream and filter but not quite done...)
    TO DO
  
  }
  </code></pre>
  
  <p>Thank you</p>