DoubleAdder reset() method in Java with Examples Last Updated : 28 Jan, 2019 Summarize Comments Improve Suggest changes Share Like Article Like Report The java.DoubleAdder.reset() is an inbuilt method in java that resets variables maintaining the sum to zero. When the object of the class is created its initial value is zero. Syntax: public void reset() Parameters: This method does not accepts any parameter. Return Value: The method returns the reset value. Below programs illustrate the above method: Program 1: Java // Program to demonstrate the reset() method import java.lang.*; import java.util.concurrent.atomic.DoubleAdder; public class GFG { public static void main(String args[]) { DoubleAdder num = new DoubleAdder(); // add operation on num num.add(42); num.add(10); // reset operation on variable num num.reset(); // Print after add operation System.out.println(" the current value is: " + num); } } Output: the current value is: 0.0 Program 2: Java // Program to demonstrate the reset() method import java.lang.*; import java.util.concurrent.atomic.DoubleAdder; public class GFG { public static void main(String args[]) { DoubleAdder num = new DoubleAdder(); // add operation on num num.add(10); // reset operation on variable num num.reset(); // Print after add operation System.out.println(" the current value is: " + num); } } Output: the current value is: 0.0 Reference: https://docs.oracle.com/javase/8/docs/api/java/util/concurrent/atomic/DoubleAdder.html#reset-- Comment More infoAdvertise with us Next Article DoubleAdder add() method in Java with Examples T Twinkl Bajaj Follow Improve Article Tags : Misc Java Java-Functions Java-DoubleAdder Practice Tags : JavaMisc Similar Reads DoubleAdder sumThenReset() method in Java with Examples The java.DoubleAdder.sumThenReset() is an inbuilt method in java is equivalent to sum() then reset() method that is firstly the effective sum is calculated and then the value is reset to maintain the value zero. When the object of the class is created its initial value is zero. Syntax: public double 2 min read DoubleAdder sum() method in Java with Examples The java.DoubleAdder.sum() is an inbuilt method in java that returns the current sum. When the object of the class is created its initial value is zero. Syntax: public double sum() Parameters: This method does not accepts any parameter. Return Value: This method returns the current sum. Below progra 1 min read DoubleAdder add() method in Java with Examples The java.DoubleAdder.add() is an inbuilt method in java that adds the given value to the previous or initial value. When the object of the class is created its initial value is zero. Syntax: public void add(double x) Parameters: This method accepts a single parameter x that specifies the value to be 1 min read DoubleAccumulator reset() method in Java with Examples The Java.DoubleAccumulator.reset() is an inbuilt method in java that resets variables maintaining updates to the identity value. It means it only returns the reset value and does not takes any parameter. The return type is int. Syntax: public void reset() Parameters: The method does not accepts any 2 min read Set clear() method in Java with Examples The Java.util.Set.clear() method is used to remove all the elements from a Set. Using the clear() method only clears all the element from the set and not deletes the set. In other words, we can say that the clear() method is used to only empty an existing Set. Syntax: void clear() Parameters: The me 1 min read SortedSet clear() method in Java with Examples The clear() method is used to remove all the elements from a SortedSet. Using the clear() method only clears all the element from the set and not deletes the set. In other words, we can say that the clear() method is used to only empty an existing Set. Syntax: void clear() Parameters: The method doe 1 min read Like