Here you can find the source of subtract(final BigDecimal start, final BigDecimal... values)
public static BigDecimal subtract(final BigDecimal start, final BigDecimal... values)
//package com.java2s; //License from project: Apache License import java.math.BigDecimal; public class Main { /**// ww w. ja va 2 s. c o m * Subtract n BigDecimal safely (i.e. handles nulls), returns 0 */ public static BigDecimal subtract(final BigDecimal start, final BigDecimal... values) { BigDecimal total = start != null ? start : BigDecimal.ZERO; if (values != null) { for (final BigDecimal v : values) { total = doSubtract(total, v); } } return total; } /** * Subtract 2 BigDecimal safely (i.e. handles nulls) v1 - v2 */ private static BigDecimal doSubtract(final BigDecimal v1, final BigDecimal v2) { BigDecimal diff = v1; if (v1 != null && v2 != null) { diff = v1.subtract(v2); } else if (v2 != null) { diff = v2.negate(); } return diff; } /** * Returns the negate of the value, handles null. */ public static BigDecimal negate(final BigDecimal value) { return value != null ? value.negate() : null; } }