Recommended code in java
<p>How to <strong>subtract the number</strong> using <strong>var-arg method</strong>.
I've written some code but can't get perfect answer....</p>

<pre><code>public static double doSubtraction(double... ds)
    {
        double total = 0;
        for(double d : ds)
        {
            total -= d;
        }
        return total;
    }

double subtraction = doSubtraction(1,2,3);
System.out.println("Subtraction : "+subtraction);
</code></pre>

<p>Actual output: -6</p>

<p>But the expected output is (1-2-3) = -4</p>