DoubleAccumulator accumulate() method in Java with Examples
The Java.DoubleAccumulator.accumulate() method is an inbuilt method in Java that updates with the given value in this DoubleAccumulator instance. It means that it takes a double value as a parameter and adds it up to this instance of DoubleAccumulator on which it is called.
public void accumulate(double valueToBeAccumulated)
Parameters: This method accepts a single mandatory parameter valueToBeAccumulated which is the double value to be updated in the current instance of this DoubleAccumulator.
Return value: This method do not return any value. It just updates this DoubleAccumulator.
Program below demonstrates the function:
Current DoubleAccumulator value is: 0.0 Updated DoubleAccumulator value is: 2.0
Current DoubleAccumulator value is: 0.0 Updated DoubleAccumulator value is: 42.2