LongAccumulator accumulate() method in Java with examples
The java.LongAccumulator.accumulate() is an inbuilt method in java that updates a particular LongAccumulator object with the given value.
Attention reader! Don’t stop learning now. Get hold of all the important Java Foundation and Collections concepts with the Fundamentals of Java and Java Collections Course at a student-friendly price and become industry ready. To complete your preparation from learning a language to DS Algo and many more, please refer Complete Interview Preparation Course.
public void accumulate(long x)
Parameters: The method accepts a single parameter x that is the value by which the current LongAccumulator object is to be update.
Return Value: The method returns the updated value.
Below programs illustrate the above method:
After update the value is: 2
After update the value is: 5