DoubleAdder reset() method in Java with Examples Last Updated : 28 Jan, 2019 Comments Improve Suggest changes 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 reset() 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 toString() method in Java with Examples The java.DoubleAdder.toString() is an inbuilt method in java that returns the String representation of the sum() method. When the object of the class is created its initial value is zero. Syntax: public String toString() Parameters: This method does not accepts any parameter. Return Value: The metho 2 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 Buffer reset() methods in Java with Examples The reset() method of java.nio.Buffer Class is used to reset this buffer's position to the previously-marked position. Invoking this method neither changes nor discards the mark's value.Syntax: public Buffer reset() Return Value: This method returns this buffer.Below are the examples to illustrate t 2 min read BufferedReader reset() method in Java with Examples The reset() method of BufferedReader class in Java is used to fix or mark the position at the last marked position so that the same byte can be read again. Syntax: public void reset() throws IOException Overrides: It overrides the reset() method of Reader class. Parameters: The method does not accep 3 min read ByteBuffer reset() methods in Java with Examples The reset() method of java.nio.ByteBuffer Class is used to reset this buffer's position to the previously-marked position. Invoking this method neither changes nor discards the mark's value. Syntax: public ByteBuffer reset() Return Value: This method returns this buffer. Below are the examples to il 2 min read Like